I want to use custom namespace in our RedisAdapter to cache in our Symfony4 app. However, when i want to set arguments like this in our services.yaml;
cache.adapter.redis:
class: SymfonyComponentCacheAdapterRedisAdapter
arguments:
- '@Redis'
- 'app'
I see this error message:
SymfonyComponentCacheTraitsRedisTrait::init() expects parameter 1 to be Redis, RedisArray, RedisCluster or PredisClientInterface, string given.
By the way, our cache config(config/packages/cache.yaml) is simple like below. So, how can I set namespace directly from any config?
cache:
app: cache.adapter.redis
default_redis_provider: 'redis://%env(REDIS_HOST)%:%env(REDIS_PORT)%'
2
Answers
I solved it with this config:
If you need the namespace to be interoperable with a third-party app,
you can take control over auto-generation by setting the
namespace
attribute of thecache.pool
service tag.For example, you can override the service definition of the adapter:
more details here: https://github.com/symfony/symfony-docs/pull/12527