SncRedisBundle
SncRedisBundle copied to clipboard
predis cluster support environment variables
SncRedis config does not support env variables of "json" type, at least for dsn property.
Example .env
REDIS_SENTINELS="[\"redis://redis-sentinel1.dev:26379\", \"redis://redis-sentinel2.dev:26379\", \"redis://redis-sentinel3.dev:26379\"]"
Example config
snc_redis:
clients:
default:
type: predis
alias: default
dsn: '%env(json:REDIS_SENTINELS)%'
PHP warnings
PHP Warning: strrpos() expects parameter 1 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 172
PHP Warning: preg_match() expects parameter 2 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 185
PHP Warning: preg_match() expects parameter 2 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 190
PHP Warning: preg_match() expects parameter 2 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 203
PHP Warning: strpos() expects parameter 1 to be string, array given in /home/app/src/vendor/snc/redis-bundle/DependencyInjection/Configuration/RedisDsn.php on line 212
JSON support would simplify SncRedis config as sentinel dsn count may differ in different enviroments.
It should be noted that support for advanced environment variables was added in Symfony 3.4 and currently this bundle still supports 2.x.
Is there any chance this could be implemented soon? Currently I have to use multiple environment variables like this:
dsn:
- 'redis://%env(REDIS_SERVER_1)%'
- 'redis://%env(REDIS_SERVER_2)%'
- 'redis://%env(REDIS_SERVER_3)%'
@codegain Feel free to send a PR, I will be happy to review it.
For phpredis at least, this is supported since https://github.com/snc/SncRedisBundle/pull/594