diff --git a/README.markdown b/README.markdown index a80cb402..69ed0ff8 100644 --- a/README.markdown +++ b/README.markdown @@ -32,13 +32,16 @@ Predis relies on the autoloading features of PHP and complies with the for interoperability with most of the major frameworks and libraries. When used in simple projects or scripts you might need to define an autoloader function: - spl_autoload_register(function($class) { - $file = PREDIS_BASE_PATH . strtr($class, '\\', '/') . '.php'; - if (file_exists($file)) { - require $file; - return true; - } - }); +``` php +set('library', 'predis'); - $value = $redis->get('library'); +``` php +set('library', 'predis'); +$value = $redis->get('library'); +``` You can also use an URI string or an array-based dictionary to specify the connection parameters: - $redis = new Predis\Client('tcp://10.0.0.1:6379'); +``` php + 'tcp', - 'host' => '10.0.0.1', - 'port' => 6379, - )); +$redis = new Predis\Client(array( + 'scheme' => 'tcp', + 'host' => '10.0.0.1', + 'port' => 6379, +)); +``` ### Pipelining multiple commands to multiple instances of Redis with client-side sharding ### @@ -78,17 +87,20 @@ in one go. Furthermore, pipelining works transparently even on aggregated connec in fact, supports client-side sharding of data using consistent-hashing on keys and clustered connections are supported natively by the client class. - $redis = new Predis\Client(array( - array('host' => '10.0.0.1', 'port' => 6379), - array('host' => '10.0.0.2', 'port' => 6379) - )); +``` php + '10.0.0.1', 'port' => 6379), + array('host' => '10.0.0.2', 'port' => 6379) +)); - $replies = $redis->pipeline(function($pipe) { - for ($i = 0; $i < 1000; $i++) { - $pipe->set("key:$i", str_pad($i, 4, '0', 0)); - $pipe->get("key:$i"); - } - }); +$replies = $redis->pipeline(function($pipe) { + for ($i = 0; $i < 1000; $i++) { + $pipe->set("key:$i", str_pad($i, 4, '0', 0)); + $pipe->get("key:$i"); + } +}); +``` ### Overriding standard connection classes with custom ones ### @@ -97,13 +109,15 @@ Predis allows developers to create new connection classes to add support for new or override the existing ones to provide a different implementation compared to the default classes. This can be obtained by subclassing the Predis\Network\IConnectionSingle interface. - class MyConnectionClass implements Predis\Network\IConnectionSingle { - // implementation goes here - } +``` php +getProfile()->defineCommand('newcmd', 'BrandNewRedisCommand'); - $redis->newcmd(); +$redis = new Predis\Client(); +$redis->getProfile()->defineCommand('newcmd', 'BrandNewRedisCommand'); +$redis->newcmd(); +``` ## Development ##