Options
Relay supports all of PhpRedis’ setOption() options and comes with its own:
OPT_USE_CACHEOPT_PHPREDIS_COMPATIBILITYOPT_CLIENT_INVALIDATIONSOPT_ALLOW_PATTERNSOPT_IGNORE_PATTERNSOPT_THROW_ON_ERROR
OPT_USE_CACHE
By default Relay will cache keys, however sometimes you may want to instantiate an object that is just a Redis client and faster alternative to PhpRedis, without caching any keys.
$relay = new Relay;
$relay->setOption(Relay::OPT_USE_CACHE, false); // must be set before connecting
$relay->connect();
OPT_PHPREDIS_COMPATIBILITY
By default Relay will act exactly like PhpRedis. If desired, Relay can return more precise values and throw exceptions when errors occur. Read more….
OPT_CLIENT_INVALIDATIONS
Applications that can’t tolerate duplicate event callbacks can disable client-side invalidation events. Read more….
OPT_ALLOW_PATTERNS
When OPT_ALLOW_PATTERNS is set only keys matching the patterns will be stored in Relay’s in-memory cache and trigger invalidation events.
The OPT_IGNORE_PATTERNS option may be used in combination with OPT_ALLOW_PATTERNS to exclude additional keys from being cached.
$relay->setOption(Relay::OPT_ALLOW_PATTERNS, [
'sessions:*',
// ...
]);
OPT_IGNORE_PATTERNS
Keys matching these patterns will not be stored in Relay’s in-memory cache and not trigger invalidation events.
$relay->setOption(Relay::OPT_IGNORE_PATTERNS, [
'analytics:*',
// ...
]);
OPT_THROW_ON_ERROR
You may configure Relay to throw exceptions when read-errors occur, instead of returning false like PhpRedis.
$relay = new Relay;
$relay->set('name', 'Picard');
$relay->hgetall('name'); // false
$relay->setOption(Relay::OPT_THROW_ON_ERROR, true);
$relay->hgetall('name'); // throws `Relay\Exception`
PhpRedis options
Relay supports all of PhpRedis’ options:
OPT_BACKOFF_ALGORITHMOPT_BACKOFF_BASEOPT_BACKOFF_CAPOPT_COMPRESSION_LEVELOPT_COMPRESSIONOPT_MAX_RETRIESOPT_NULL_MULTIBULK_AS_NULLOPT_PREFIXOPT_READ_TIMEOUTOPT_REPLY_LITERALOPT_SCANOPT_TCP_KEEPALIVE