-
-
Notifications
You must be signed in to change notification settings - Fork 994
Using Relay
Till Krüss edited this page Mar 2, 2023
·
24 revisions
THIS PAGE IS A ROUGH DRAFT FOR THE PENDING 3.0 RELEASE
As of v3.0, Predis comes with a native integration for the Relay PHP extension, which brings major performance gains by:
- caching a partial replica of the Redis dataset in PHP shared runtime memory
- supporting fast data compression to reduce network and Redis memory usage by ~75%
Using Relay is as simple as installing the extension and defining the connection:
$client = new Predis\Client('tcp://127.0.0.1', [
'connections' => 'relay',
]);When using Relay, please note that:
- Relay will ignore the
exceptionsoption and always throw when error occur - Relay treats all connections as persistent and the
persistentoption is ignored - Transactions
- The Predis integration has not been tested with aggregate connections (such as Sentinel or Cluster)
- Some commands are currently unsupported:
MONITOR-
WATCH/UNWATCH -
SUBSCRIBE/UNSUBSCRIBE -
PSUBSCRIBE/PUNSUBSCRIBE_Test PUBLISH-
COMMAND(WIP)
Search for the relay-incompatible group in the test suite to see which tests exactly don't pass.
- supported algorithms: php, json, msgpack, igbinary
- when serializing php objects, you must use php / igbinary
- works in combination with
compressionoption
- supported algorithms: lzf, lz4, zstd
- works with
serializeroption
- Supports event callbacks
$client = new Predis\Client('tcp://127.0.0.1', [
'connections' => 'relay',
]);
$client->getConnection()
->getClient()
->listen(function (\Relay\Event $event) {
match ($event->type) {
$event::Flushed => flushLocalCache(),
$event::Invalidated => deleteKeyFromCache($event->key),
};
});