Skip to content

Lightweight PHP Redis client that can run standalone or wrap phpredis.

License

Notifications You must be signed in to change notification settings

gruenspar/credis-magento

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Credis

Credis is a lightweight interface to the Redis key-value store which wraps the phpredis library when available for better performance. This project was forked from one of the many redisent forks.

Getting Started

Credis uses methods named the same as Redis commands, and translates return values to the appropriate PHP equivalents.

require 'Credis/Client.php';
$redis = new Credis_Client('localhost');
$redis->set('awesome', 'absolutely');
echo sprintf('Is Credis awesome? %s.\n', $redis->get('awesome'));

// When arrays are given as arguments they are flattened automatically
$redis->rpush('particles', array('proton','electron','neutron'));
$particles = $redis->lrange('particles', 0, -1);

Redis error responses will be wrapped in a CredisException class and thrown.

Clustering your servers

Credis also includes a way for developers to fully utilize the scalability of Redis with multiple servers and consistent hashing. Using the Credis_Cluster class, you can use Credis the same way, except that keys will be hashed across multiple servers. Here is how to set up a cluster:

require 'Credis/Client.php';
require 'Credis/Cluster.php';

$cluster = new Credis_Cluster(array(
    'alpha' => array('host' => '127.0.0.1', 'port' => 6379),
    'beta'  => array('host' => '127.0.0.1', 'port' => 6380),
));
$cluster->set('key','value');
$cluster->to('alpha')->info();

About

© 2011 Colin Mollenhour © 2009 Justin Poliey

About

Lightweight PHP Redis client that can run standalone or wrap phpredis.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 99.2%
  • Shell 0.8%