Use Redis to Get the Caching Doctrine in Symfony 2

I am trying to use Redis to cache the result of a query and APC for metacache. According to the Symfony docs, all I have to do is.

doctrine: orm: auto_mapping: true metadata_cache_driver: apc result_cache_driver: type: redis host: localhost instance_class: Redis 

Is it right to set the cache property for the doctrine? Also, when I google "use redis with symfony", I get results that tell me to use the SNCRedis package.

Do I need to use the SNCRedis package to use Redis for doctrine in Symfony? Also, what benefit does it provide on top of Symfony by default. I'm just a little confused here, as the documentation is sparse when it comes to caching in Symfony related to Doctrine. Can someone please let me know this.

+7
symfony doctrine redis
source share
1 answer

The configuration added for the result cache only configures the strategy. You still need to explicitly specify the doctrine for caching results for specific queries:

 $query->useResultCache(true); 

Learn more about this in the Doctrine Docs Cache .

The documentation in Symfony is sparse, as this is not a special feature of Symfony. Read the doctrine documentation. Use only Symfony docs to learn how to configure Doctrine.

You do not need Redis packages, since the Redis caching strategy is implemented by the doctrine package doctrine / cache . You do not need to worry about how to use it. Just configure the cache as described in the docs.

+11
source share

All Articles