Skip to content

Commit eeb07c3

Browse files
authored
Update redis_adapter.rst
Using RedisTagAwareAdapter, Redis maxmemory-policy has to be "noeviction" or "volatile-*"
1 parent 6c98343 commit eeb07c3

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

components/cache/adapters/redis_adapter.rst

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,8 @@ Available Options
228228

229229
.. _redis-tag-aware-adapter:
230230

231-
Working with Tags
232-
-----------------
233-
234-
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::
235-
236-
use Symfony\Component\Cache\Adapter\RedisAdapter;
237-
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
238-
239-
$client = RedisAdapter::createConnection('redis://localhost');
240-
$cache = new RedisTagAwareAdapter($client);
241-
242231
Configuring Redis
243-
~~~~~~~~~~~~~~~~~
232+
-----------------
244233

245234
When using Redis as cache, you should configure the ``maxmemory`` and ``maxmemory-policy``
246235
settings. By setting ``maxmemory``, you limit how much memory Redis is allowed to consume.
@@ -255,6 +244,21 @@ try to add data when no memory is available. An example setting could look as fo
255244
maxmemory 100mb
256245
maxmemory-policy allkeys-lru
257246
247+
Working with Tags
248+
-----------------
249+
250+
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::
251+
252+
use Symfony\Component\Cache\Adapter\RedisAdapter;
253+
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
254+
255+
$client = RedisAdapter::createConnection('redis://localhost');
256+
$cache = new RedisTagAwareAdapter($client);
257+
258+
.. note::
259+
260+
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.
261+
258262
Read more about this topic in the official `Redis LRU Cache Documentation`_.
259263

260264
.. _`Data Source Name (DSN)`: https://en.wikipedia.org/wiki/Data_source_name

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy