PHPackages                             icyboy/credis - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. icyboy/credis

ActiveLibrary[Caching](/categories/caching)

icyboy/credis
=============

Credis is a lightweight interface to the Redis key-value store which wraps the phpredis library when available for better performance.

1.9.2(8y ago)074MITPHPPHP &gt;=5.4.0

Since Nov 19Pushed 8y ago1 watchersCompare

[ Source](https://github.com/icyxp/credis)[ Packagist](https://packagist.org/packages/icyboy/credis)[ Docs](https://github.com/icyxp/credis)[ RSS](/packages/icyboy-credis/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (15)Used By (0)

[![Build Status](https://camo.githubusercontent.com/e911c92952954b2603e0023f9eb24ba94d943b5d9ad030f98f74a746dc919f3d/68747470733a2f2f7472617669732d63692e6f72672f69637978702f6372656469732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/icyxp/credis)[![Minimum PHP Version](https://camo.githubusercontent.com/98118bf0a3c8b650013ffc8a5d96731efc81154ae06ef7133f378875dedea4f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e352d3838393242462e737667)](https://php.net/)[![Total Downloads](https://camo.githubusercontent.com/6bd756bf8dbc2de2f4d0bff68a890eaf936331e5618004f0ade41dff69e3542f/68747470733a2f2f706f7365722e707567782e6f72672f696379626f792f6372656469732f646f776e6c6f616473)](https://packagist.org/packages/icyboy/credis)[![License](https://camo.githubusercontent.com/c3c95c0458ebbf8ee63ade7ff9b557b9ec1f00dffaff1f6c03ec9695eb9197c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a6363686176657a732f6372656469732e737667)](https://github.com/icyxp/credis/blob/master/LICENSE)

Credis
======

[](#credis)

Credis is a lightweight interface to the [Redis](http://redis.io/) key-value store which wraps the [phpredis](https://github.com/nicolasff/phpredis)library when available for better performance. This project was forked from one of the many redisent forks.

Getting Started
---------------

[](#getting-started)

Credis\_Client 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.

Credis\_Client also supports transparent command renaming. Write code using the original command names and the client will send the aliased commands to the server transparently. Specify the renamed commands using a prefix for md5, a callable function, individual aliases, or an array map of aliases. See "Redis Security": for more info.

Clustering your servers
-----------------------

[](#clustering-your-servers)

Credis also includes a way for developers to fully utilize the scalability of Redis with multiple servers and [consistent hashing](http://en.wikipedia.org/wiki/Consistent_hashing). Using the [Credis\_Cluster](Cluster.php) 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:

### Basic clustering example

[](#basic-clustering-example)

```
