Description
Symfony version(s) affected: tested with 5.1
Description
Symfony\Component\Lock\Store\RedisStore::__construct() accepts instance of \RedisCluster
as argument but it does not accept Symfony\Component\Cache\Traits\RedisClusterProxy
. Since Symfony\Component\Lock\Store\StoreFactory
forces lazy connections when creating Redis client, you will always get RedisClusterProxy instead of \RedisCluster if your DSN has ?redis_cluster=1
.
We are using Redis cluster and when we switched from Predis to php-redis, it resulted in following error because of this:
_Error: ""Symfony\Component\Lock\Store\RedisStore::_construct()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "Symfony\Component\Cache\Traits\RedisClusterProxy" given."
I understand Redis cluster is not reliable for storing locks but if RedisStore accepts \RedisCluster as argument, it should also accept decorator RedisClusterProxy.
How to reproduce
Using Redis as lock store, add ?redis_cluster=1
to your lock store DSN.
Possible Solution
Update RedisStore::__construct() to accept RedisClusterProxy as argument.
Another option if Redis cluster should never be used with Lock, remove \RedisCluster and RedisClusterProxy references from RedisStore and StoreFactory::createStore() to avoid confusion.
Additional context