A CodeIgniter library to interact with Redis
Pull request Compare This branch is 65 commits behind joelcox:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


CodeIgniter Redis

A CodeIgniter interface for the Redis data store. This library tries to adhere 100% to the defined protocol, including responses.

NOTE: This library is still under heavy development. Things may change in future releases.


  1. PHP 5+
  2. CodeIgniter 2.0+
  3. A Redis server compatible with the unified request protocol (Redis 1.2+)


This library is also released as a Spark. If you use this library in any other way, don't copy the autoload.php to your config directory.



This library expects a configuration file to function correctly. A template for this file is provided with the library.

Generic command

You can execute any command using the command() method, just like you're using redis-cli.


This library also support PHP's overloading functionality. This means you can call undefined methods, which are then dynamically created for you. These calls are routed to the generic __call() method. Undefined methods take as much arguments as you please.

$this->redis->hmset('foohash foofield1 "bar1" foofield2 "bar2"');


Set a new key with a value

$this->redis->set('foo', 'bar');

Get a value by its key


Delete a key/keys


You can also pass a list of keys to be deleted as an array, space separated list or comma separated list. The space method is according to the defined protocol.

$this->redis->del(array('foo', 'foo2'));
$this->redis->del('foo foo2));
$this->redis->del('foo, foo2));


I am a firm believer of social coding, so if when you find a bug, please fork my 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).


This library is released under the MIT license.

Thanks to