CodeIgniter Redis
=================
This library is deprecated. We recommend migrating to [Predis](https://github.com/nrk/predis).
----------------------------------------------------------------------------------------------
A CodeIgniter interface for the Redis data store. This library tries to adhere to the [defined protocol](http://redis.io/topics/protocol), including responses.
[![Build Status](https://secure.travis-ci.org/joelcox/codeigniter-redis.png?branch=develop)](http://travis-ci.org/joelcox/codeigniter-redis)
Requirements
------------
1. PHP 5+
2. [CodeIgniter 2.0+](http://codeigniter.com)
3. A [Redis server](http://redis.io) compatible with the unified request protocol (Redis 1.2+)
Spark
-----
This library is also released as a [Spark](http://getsparks.org). If you use this library in any other way, **don't copy the autoload.php to your config directory**.
Breaking changes
----------------
As of v0.4, this library does not longer support the plain text syntax for overloaded commands (i.e. `$this->redis->set('foo bar')`). Please pass extra command arguments as real PHP arguments instead (i.e. `$this->redis->set('foo', 'bar')`). You can still use the plain text syntax using the `command` method (e.g. `$this->redis->command('SET foo bar')`) if you need this functionality.
Documentation
-------------
### Configuration
This library expects a configuration file to function correctly. A template for this file is provided with the library.
### Multiple connection groups
If you want to use multiple Redis servers, you can add an additional array to the configuration file with the details of this server.
```
$config['redis_slave']['host'] = 'otherhost';
$config['redis_slave']['port'] = '6379';
$config['redis_slave']['password'] = '';
```
To use this connection group, you must create a new instance of this library like this:
```
$this->load->library('redis', array('connection_group' => 'slave'), 'redis_slave');
$this->redis_slave->command('PING')
```
This will create a new object named `redis_slave` which will use the configuration options of the `slave` connection group. The default connection group is loaded by when no connection group is specified.
### Generic command
You can execute any command using the `command()` method, just like you're using [redis-cli](http://code.google.com/p/redis/wiki/RedisCLI).
$this->redis->command('PING');
This library also support PHP's [overloading](http://php.net/manual/en/language.oop5.overloading.php) functionality. This means you can call undefined methods, which are then dynamically created for you. These calls are routed to the generic `__call()` method. You can also pass in arrays.
$this->redis->hmset('foohash', array('key1' => 'value1', 'key2' => 'value2'));
### Examples
Set a new key with a value and retrieve it again
$this->redis->set('foo', 'bar');
Get a value by its key
$this->redis->get('foo');
Delete a bunch of keys
$this->redis->del(array('foo', 'foo2'));
### Working with lists
Because PHP lacks basic list and dictionary/map/hash data types, this library tries to detect this on its own. This is done by using the following heuristic; if the smallest key in an array equals 0 and the largest key equals the length of the array - 1, the array is considered to be a list. In this case, the library's internals will automatically strip away the keys before passing the array to the Redis server.
Contributing
------------
I am a firm believer of social coding, so if you find a bug, please fork this code on [GitHub](http://github.com/joelcox/codeigniter-redis) and squash it. I will be happy to merge it back in to the code base (and add you to the "Thanks to" section). If you're not too comfortable using Git or messing with the inner workings of this library, please open [a new issue](http://github.com/joelcox/codeigniter-redis/issues).
License
-------
This library is released under the MIT license.
Thanks to
---------
* [Eric Greer](https://github.com/integrii)
* [Martijn Pannevis](http://martijnpannevis.nl/blog/)
* [Muhammad Fikri](https://github.com/swznd) for fixing the 8kb choking bug.
* [Alex Williams](http://www.alexwilliams.ca) for his working on connection groups. ✨
* [Daniel Hunsaker](http://danhunsaker.wordpress.com) for fixing a bug related to passing 3+ arguments and his input on different issues.
* [Tim Post](http://alertfalse.com/) for taking the time to fix a long standing 'space' bug.
* [Lucas Nolte](http://91media.de/) for filing bug reports and submitting patches.
Cheers,
–– [Joël Cox](http://joelcox.nl)
徐浪老师
- 粉丝: 8312
- 资源: 1万+
最新资源
- C语言文件读写操作详解及示例代码
- 个人毕设基于ResNet的手写公式识别系统python源码+运行教程+模型+数据+超详细注释.zip
- 大规模语言模型在规划任务中的角色与局限 - 一种新的LLM-Modulo框架视角
- 钢材器材破损铁锈检测69-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 推荐一款JTools的call-this-method插件
- matlab《基于图论的城市道路交通网络流量拥堵优化分析》+源码+文档说明+图论建模(高分作品)
- 基于spring boot的仓库物流管理系统(springboot+mybatis-plus+shiro+mysql+layui前端框架),可作为练习项目、毕业设计、课程设计欢迎Fork,你也.zip
- Python基于CNN深度学习的遥感landsat影像地物分类源代码+训练好的模型
- 矿井测量第三章-矿井联系测量PPT课件共182页(转pdf格式)
- 大型语言模型与经典规划器融合增强复杂任务规划能力
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈