Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7e04d5a

Browse filesBrowse files
committed
Merge branch '4.4' into 5.1
* 4.4: Minor: Rename ref. refs #14081 Add documentation about RedisTagAwareAdapter
2 parents 60c44f2 + caa6858 commit 7e04d5a
Copy full SHA for 7e04d5a

File tree

2 files changed

+19
-0
lines changed
Filter options

2 files changed

+19
-0
lines changed

‎components/cache/adapters/redis_adapter.rst

Copy file name to clipboardExpand all lines: components/cache/adapters/redis_adapter.rst
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,20 @@ Available Options
180180
When using the `Predis`_ library some additional Predis-specific options are available.
181181
Reference the `Predis Connection Parameters`_ documentation for more information.
182182

183+
.. _redis-tag-aware-adapter:
184+
185+
Working with Tags
186+
-----------------
187+
188+
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::
189+
190+
use Symfony\Component\Cache\Adapter\RedisAdapter;
191+
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
192+
193+
$client = RedisAdapter::createConnection('redis://localhost');
194+
$cache = new RedisTagAwareAdapter($client);
195+
196+
183197
.. _`Data Source Name (DSN)`: https://en.wikipedia.org/wiki/Data_source_name
184198
.. _`Redis server`: https://redis.io/
185199
.. _`Redis`: https://github.com/phpredis/phpredis

‎components/cache/cache_invalidation.rst

Copy file name to clipboardExpand all lines: components/cache/cache_invalidation.rst
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ To store tags, you need to wrap a cache adapter with the
5858
:method:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapterInterface::invalidateTags`
5959
method.
6060

61+
.. note::
62+
63+
When using a Redis backend, consider using :ref:`RedisTagAwareAdapter <redis-tag-aware-adapter>`
64+
which is optimized for this purpose.
65+
6166
The :class:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapter` class implements
6267
instantaneous invalidation (time complexity is ``O(N)`` where ``N`` is the number
6368
of invalidated tags). It needs one or two cache adapters: the first required

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.