From 27ef0bee03b2456623c547eb634e661055e04fd9 Mon Sep 17 00:00:00 2001 From: Cyanat <65961341+Cyanat@users.noreply.github.com> Date: Wed, 26 Jul 2023 11:44:29 +0200 Subject: [PATCH] Update redis_adapter.rst Using RedisTagAwareAdapter, Redis maxmemory-policy has to be "noeviction" or "volatile-*" --- components/cache/adapters/redis_adapter.rst | 28 ++++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/components/cache/adapters/redis_adapter.rst b/components/cache/adapters/redis_adapter.rst index a7530e6d3f0..6f74b53dc63 100644 --- a/components/cache/adapters/redis_adapter.rst +++ b/components/cache/adapters/redis_adapter.rst @@ -220,19 +220,8 @@ Available Options .. _redis-tag-aware-adapter: -Working with Tags ------------------ - -In order to use tag-based invalidation, you can wrap your adapter in :class:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapter`, but when Redis is used as backend, it's often more interesting to use the dedicated :class:`Symfony\\Component\\Cache\\Adapter\\RedisTagAwareAdapter`. Since tag invalidation logic is implemented in Redis itself, this adapter offers better performance when using tag-based invalidation:: - - use Symfony\Component\Cache\Adapter\RedisAdapter; - use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; - - $client = RedisAdapter::createConnection('redis://localhost'); - $cache = new RedisTagAwareAdapter($client); - Configuring Redis -~~~~~~~~~~~~~~~~~ +----------------- When using Redis as cache, you should configure the ``maxmemory`` and ``maxmemory-policy`` settings. By setting ``maxmemory``, you limit how much memory Redis is allowed to consume. @@ -247,6 +236,21 @@ try to add data when no memory is available. An example setting could look as fo maxmemory 100mb maxmemory-policy allkeys-lru +Working with Tags +----------------- + +In order to use tag-based invalidation, you can wrap your adapter in :class:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapter`, but when Redis is used as backend, it's often more interesting to use the dedicated :class:`Symfony\\Component\\Cache\\Adapter\\RedisTagAwareAdapter`. Since tag invalidation logic is implemented in Redis itself, this adapter offers better performance when using tag-based invalidation:: + + use Symfony\Component\Cache\Adapter\RedisAdapter; + use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; + + $client = RedisAdapter::createConnection('redis://localhost'); + $cache = new RedisTagAwareAdapter($client); + +.. note:: + + When using RedisTagAwareAdapter, in order to maintain relationships between tags and cache items, you have to use either ``noeviction`` or ``volatile-*`` in the Redis ``maxmemory-policy`` eviction policy. + Read more about this topic in the official `Redis LRU Cache Documentation`_. .. _`Data Source Name (DSN)`: https://en.wikipedia.org/wiki/Data_source_name
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: