Skip to content

Commit 93b7fbc

Browse files
committed
minor #18614 [Cache] Update redis_adapter.rst (Cyanat)
This PR was submitted for the 6.3 branch but it was merged into the 6.2 branch instead. Discussion ---------- [Cache] Update redis_adapter.rst Using RedisTagAwareAdapter, Redis maxmemory-policy has to be "noeviction" or "volatile-*" <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- 27ef0be Update redis_adapter.rst
2 parents 9aef409 + 27ef0be commit 93b7fbc

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
@@ -220,19 +220,8 @@ Available Options
220220

221221
.. _redis-tag-aware-adapter:
222222

223-
Working with Tags
224-
-----------------
225-
226-
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::
227-
228-
use Symfony\Component\Cache\Adapter\RedisAdapter;
229-
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
230-
231-
$client = RedisAdapter::createConnection('redis://localhost');
232-
$cache = new RedisTagAwareAdapter($client);
233-
234223
Configuring Redis
235-
~~~~~~~~~~~~~~~~~
224+
-----------------
236225

237226
When using Redis as cache, you should configure the ``maxmemory`` and ``maxmemory-policy``
238227
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
247236
maxmemory 100mb
248237
maxmemory-policy allkeys-lru
249238
239+
Working with Tags
240+
-----------------
241+
242+
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::
243+
244+
use Symfony\Component\Cache\Adapter\RedisAdapter;
245+
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
246+
247+
$client = RedisAdapter::createConnection('redis://localhost');
248+
$cache = new RedisTagAwareAdapter($client);
249+
250+
.. note::
251+
252+
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.
253+
250254
Read more about this topic in the official `Redis LRU Cache Documentation`_.
251255

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

0 commit comments

Comments
 (0)