Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Relay\Sentinel compatibility #723

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/DependencyInjection/SncRedisExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use InvalidArgumentException;
use LogicException;
use RedisSentinel;
use Relay\Sentinel;
use Snc\RedisBundle\DependencyInjection\Configuration\Configuration;
use Snc\RedisBundle\DependencyInjection\Configuration\RedisDsn;
use Snc\RedisBundle\DependencyInjection\Configuration\RedisEnvDsn;
Expand Down Expand Up @@ -222,9 +223,10 @@ private function loadPhpredisClient(array $options, ContainerBuilder $container)
);

unset($options['options']['commands']);
$sentinelClass = $options['type'] === 'relay' ? Sentinel::class : RedisSentinel::class;

$phpredisDef = new Definition($phpredisClientClass, [
$hasSentinelOption ? RedisSentinel::class : $phpredisClientClass,
$hasSentinelOption ? $sentinelClass : $phpredisClientClass,
array_map('strval', $options['dsns']),
$options['options'],
$options['alias'],
Expand Down
6 changes: 3 additions & 3 deletions src/Factory/PhpredisClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ private function createClient(RedisDsn $dsn, string $class, string $alias, array
}

if (isset($options['prefix'])) {
$client->setOption(Redis::OPT_PREFIX, $options['prefix']);
$client->setOption($class::OPT_PREFIX, $options['prefix']);
}

if (isset($options['read_write_timeout'])) {
$client->setOption(Redis::OPT_READ_TIMEOUT, (float) $options['read_write_timeout']);
$client->setOption($class::OPT_READ_TIMEOUT, (float) $options['read_write_timeout']);
}

if (isset($options['serialization'])) {
$client->setOption(Redis::OPT_SERIALIZER, $this->loadSerializationType($options['serialization']));
$client->setOption($class::OPT_SERIALIZER, $this->loadSerializationType($options['serialization']));
}

return $client;
Expand Down
Loading