|
@@ -22,9 +22,9 @@ on the online [wiki](https://github.com/nrk/predis/wiki).
|
|
|
|
|
|
- Wide range of Redis versions supported (from __1.2__ to __3.0__ and __unstable__) using profiles.
|
|
|
- Clustering via client-side sharding using consistent hashing or custom distributors.
|
|
|
-- Smart support for [redis-cluster](http://redis.io/topics/cluster-spec) (Redis >= 3.0).
|
|
|
+- Smart support for [redis-cluster](http://redis.io/topics/cluster-tutorial) (Redis >= 3.0).
|
|
|
- Support for master-slave replication configurations (write on master, read from slaves).
|
|
|
-- Transparent key prefixing for all Redis commands.
|
|
|
+- Transparent key prefixing for all known Redis commands.
|
|
|
- Command pipelining (works on both single and aggregate connections).
|
|
|
- Abstraction for Redis transactions (Redis >= 2.0) supporting CAS operations (Redis >= 2.2).
|
|
|
- Abstraction for Lua scripting (Redis >= 2.6) with automatic switching between `EVALSHA` or `EVAL`.
|
|
@@ -179,43 +179,7 @@ __NOTE__: the method `transaction()` is available since `v0.8.5`, older versions
|
|
|
for the same purpose but it has been deprecated and will be removed in the next major release.
|
|
|
|
|
|
|
|
|
-### Customizable connection backends ###
|
|
|
-
|
|
|
-Predis can use different connection backends to connect to Redis. Two of them leverage a third party
|
|
|
-extension such as [phpiredis](https://github.com/nrk/phpiredis) resulting in major performance gains
|
|
|
-especially when dealing with big multibulk responses. While one is based on PHP streams, the other
|
|
|
-is based on socket resources provided by `ext-socket`. Both support TCP/IP or UNIX domain sockets:
|
|
|
-
|
|
|
-```php
|
|
|
-$client = new Predis\Client('tcp://127.0.0.1', [
|
|
|
- 'connections' => [
|
|
|
- 'tcp' => 'Predis\Connection\PhpiredisStreamConnection', // PHP streams
|
|
|
- 'unix' => 'Predis\Connection\PhpiredisConnection', // ext-socket
|
|
|
- ],
|
|
|
-]);
|
|
|
-```
|
|
|
-
|
|
|
-Developers can create their own connection classes to add support for new network backends, extend
|
|
|
-existing ones or provide completely different implementations. Connection classes must implement
|
|
|
-`Predis\Connection\SingleConnectionInterface` or extend `Predis\Connection\AbstractConnection`:
|
|
|
-
|
|
|
-```php
|
|
|
-class MyConnectionClass implements Predis\Connection\SingleConnectionInterface
|
|
|
-{
|
|
|
- // Implementation goes here...
|
|
|
-}
|
|
|
-
|
|
|
-// Use MyConnectionClass to handle connections for the `tcp` scheme:
|
|
|
-$client = new Predis\Client('tcp://127.0.0.1', [
|
|
|
- 'connections' => ['tcp' => 'MyConnectionClass'],
|
|
|
-]);
|
|
|
-```
|
|
|
-
|
|
|
-For a more in-depth insight on how to create new connection backends you can refer to the actual
|
|
|
-implementation of the standard connection classes available in the `Predis\Connection` namespace.
|
|
|
-
|
|
|
-
|
|
|
-### Adding support for new commands ###
|
|
|
+### Adding new Redis commands ###
|
|
|
|
|
|
While we try to update Predis to stay up to date with all the commands available in Redis, you might
|
|
|
prefer to stick with an older version of the library or provide a different way to filter arguments
|
|
@@ -240,15 +204,16 @@ $response = $client->newcmd();
|
|
|
```
|
|
|
|
|
|
|
|
|
-### Scriptable commands ###
|
|
|
+### Script commands ###
|
|
|
|
|
|
-A scriptable command is just an abstraction for [Lua scripting](http://redis.io/commands/eval) that
|
|
|
-aims to simplify the usage of scripting with Redis >= 2.6. Scriptable commands can be registered in
|
|
|
-the server profile used by the client and are accessible as if they were plain Redis commands, but
|
|
|
-they define a Lua script that gets transmitted to Redis for remote execution. Internally, scriptable
|
|
|
-commands use by default [EVALSHA](http://redis.io/commands/evalsha) and identify a Lua script by its
|
|
|
-SHA1 hash to save bandwidth but [EVAL](http://redis.io/commands/eval) is automatically preferred as
|
|
|
-a fall back when needed:
|
|
|
+While it is possible to leverage [Lua scripting](http://redis.io/commands/eval) on Redis 2.6+ using
|
|
|
+[EVAL](http://redis.io/commands/eval) and [EVALSHA](http://redis.io/commands/evalsha), Predis offers
|
|
|
+script commands as an higher level abstraction aiming to make things simple. Script commands can be
|
|
|
+registered in the server profile used by the client and are accessible as if they were plain Redis
|
|
|
+commands, but they define a Lua script that gets transmitted to the server for remote execution.
|
|
|
+Internally they use [EVALSHA](http://redis.io/commands/evalsha) by default and identify a Lua script
|
|
|
+by its SHA1 hash to save bandwidth, but [EVAL](http://redis.io/commands/eval) is automatically used
|
|
|
+as a fall back when needed:
|
|
|
|
|
|
```php
|
|
|
// Define a new scriptable command by extending Predis\Command\ScriptedCommand:
|
|
@@ -278,6 +243,42 @@ $response = $client->lpushrand('random_values', $seed = mt_rand());
|
|
|
```
|
|
|
|
|
|
|
|
|
+### Customizable connection backends ###
|
|
|
+
|
|
|
+Predis can use different connection backends to connect to Redis. Two of them leverage a third party
|
|
|
+extension such as [phpiredis](https://github.com/nrk/phpiredis) resulting in major performance gains
|
|
|
+especially when dealing with big multibulk responses. While one is based on PHP streams, the other
|
|
|
+is based on socket resources provided by `ext-socket`. Both support TCP/IP or UNIX domain sockets:
|
|
|
+
|
|
|
+```php
|
|
|
+$client = new Predis\Client('tcp://127.0.0.1', [
|
|
|
+ 'connections' => [
|
|
|
+ 'tcp' => 'Predis\Connection\PhpiredisStreamConnection', // PHP streams
|
|
|
+ 'unix' => 'Predis\Connection\PhpiredisConnection', // ext-socket
|
|
|
+ ],
|
|
|
+]);
|
|
|
+```
|
|
|
+
|
|
|
+Developers can create their own connection classes to add support for new network backends, extend
|
|
|
+existing ones or provide completely different implementations. Connection classes must implement
|
|
|
+`Predis\Connection\SingleConnectionInterface` or extend `Predis\Connection\AbstractConnection`:
|
|
|
+
|
|
|
+```php
|
|
|
+class MyConnectionClass implements Predis\Connection\SingleConnectionInterface
|
|
|
+{
|
|
|
+ // Implementation goes here...
|
|
|
+}
|
|
|
+
|
|
|
+// Use MyConnectionClass to handle connections for the `tcp` scheme:
|
|
|
+$client = new Predis\Client('tcp://127.0.0.1', [
|
|
|
+ 'connections' => ['tcp' => 'MyConnectionClass'],
|
|
|
+]);
|
|
|
+```
|
|
|
+
|
|
|
+For a more in-depth insight on how to create new connection backends you can refer to the actual
|
|
|
+implementation of the standard connection classes available in the `Predis\Connection` namespace.
|
|
|
+
|
|
|
+
|
|
|
## Development ##
|
|
|
|
|
|
|