I am trying to use Redis to cache query result and APC for metacache. As per Symfony docs all I need to do is.
doctrine:
orm:
auto_mapping: true
metadata_cache_driver: apc
result_cache_driver:
type: redis
host: localhost
instance_class: Redis
Is this the right way to configure the cache property for doctrine? Also when I google "use redis with symfony" I get results which tells me to use SNCRedis bundle.
Is it necessary to use SNCRedis bundle to use Redis for doctrine in Symfony? Also what benefit it provides on top of Symfony defaults. I am just bit confused here since documentation is sparse when it comes to caching in Symfony with related to Doctrine. Can someone please give me any insight in this matter.
The configuration you've added for result cache only configures the strategy to use. You still need to explicitly tell doctrine to cache results for specific queries:
$query->useResultCache(true);
Learn more about it in the Doctrine's Cache docs.
Documentation in Symfony is sparse, as this is not really a Symfony specific thing. Read the doctrine documentation instead. Only use Symfony docs to learn how to configure Doctrine.
You don't need any Redis bundles, as Redis caching strategy is implemented by doctrine with the doctrine/cache package. You don't have to worry how to use it. Simply configure the cache as described in the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With