/RedisPHPlay

A fast, native PHP, redis client.

Primary LanguageJavaScript

RedisPHPlay
===========
   RedisPHPlay is a fast, full-featured, native PHP, redis client.

Goals
=====
   * fast
   * easy to use
   * fully documented
   * copious examples
   * fully unit-tested
   * translates as much as possible to native PHP datatypes:
      * status reply    boolean
      * error reply     exception
      * integer reply   integer
      * bulk reply      array(one of the above)
      * nil             null
   * support for Master/Slave replication
   * support for Clustering

Overview
========
   The RedisPHPlay library is geared towards being usable in development. This 
   is represent in a few ways: All validation exceptions have 1 supertype 
   RedisValidationException, making them easy to catch. All other exceptions are 
   RedisExceptions. Everything is documented. All input is validated. All output 
   is as typefull as possible. Speed, the library tries to use memory as 
   efficient as possible. Completenes, the library tries to implement all redis 
   commands and to encapsulate best practices surrounding it.

Contents
========
   etc/
       contains api docs, coverage docs, win32 redis binary and the settings for 
       phpdoctor (the documentation generator).
   examples/
      contains a number of examples that show how to work with the library and 
      redis in general.
         * chat/
             - a basic irc like chat server based on ajax long polling via jquery, html5's 
             sessionStorage and redis pub/sub. Supports joining channels via (/join #<channel>) 
             and sending messages. Tested in chrome, firefox.
         * pubsub.php
             - a example showing Pub/Sub functionality using multiple browser windows to simulate concurrent connections.

         * basic.php
             - examples of basic operations 
         * hashes.php
             - examples of basic hash operations 
         * lists.php
             - examples of basic list operations 
         * pipelining.php
             - benchmark showing the speedup of pipelining
         * sets.php
             - some examples of working with sets
         * sortedsets.php
             - some examples of working with sorted sets
         * transactions.php
             - some examples of how transactions work in redis
         * sharding.php
             - (WIP) examples showing the sharding/replication functionality of the library
         * twitter/
             - (WIP) simple example showing how you could store twitter messages using RedisPHPlay            
         * shardedcounter.php
             - (TODO) how to implement a highly robust, sharded counter 
               - http://code.google.com/intl/nl-NL/appengine/articles/sharding_counters.html 
               - https://sites.google.com/site/io/building-scalable-web-applications-with-google-app-engine
   library/
      the main code of RedisPHPlay. include RedisPHPlay.php to get started.
   tests/
      contains all unittests for the RedisPHPlay library and supporting code

Completion
==========
   Major features and their completion / testing percentages

                     | done % | docs % | test % |
   ----------------------------------------------
   | Manager         |    95% |     0% |   100% |
   | Client          |    95% |     0% |    67% |
   ----------------------------------------------
   | Commands        |        |        |        |
   |  Keys           |   100% |   100% |   100% |
   |  Strings        |   100% |   100% |   100% |
   |  Hashes         |   100% |   100% |   100% |
   |  Lists          |   100% |   100% |   100% |
   |  Sets           |   100% |   100% |   100% |
   |  Sorted Sets    |   100% |   100% |    52% |
   |  Pub/Sub        |   100% |   100% |     0% |
   |  Transactions   |   100% |   100% |   100% |
   |  Connection     |   100% |   100% |   100% |
   |  Server         |   100% |   100% |     0% |
   ----------------------------------------------
   | Pipelining      |    90% |    10% |     0% |
   | Partitioning    |    10% |     5% |     0% |
   | Replication     |    10% |     5% |     0% |
   ----------------------------------------------
   (83 tests, 583 assertions)
      
Example
=======
   <?php
      $redis = new RedisManager();
      $handle = $redis->connect('localhost', 6379);

      if( !$handle->AUTH('password') ) 
         die('could not authenticate');
      $handle->SET('foo', 1); // true 
      echo $handle->GET('foo'); // 1