Giter Site home page Giter Site logo

credis's Introduction

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

credis's People

Contributors

colinmollenhour avatar jdp avatar samm-git avatar rayward avatar chrisboulton avatar dchancogne avatar eb-eoliveira avatar intarstudents avatar kevburnsjr avatar ruudk avatar e-oz avatar

Watchers

James Cloos avatar Bolaji Olubajo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.