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 83fe3d7

Browse filesBrowse files
committed
Add documentation about RedisTagAwareAdapter
1 parent 4d52670 commit 83fe3d7
Copy full SHA for 83fe3d7

File tree

Expand file treeCollapse file tree

2 files changed

+18
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-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
@@ -188,6 +188,20 @@ Available Options
188188
When using the `Predis`_ library some additional Predis-specific options are available.
189189
Reference the `Predis Connection Parameters`_ documentation for more information.
190190

191+
.. _redis-tag-aware:
192+
193+
Working with Tags
194+
-----------------
195+
196+
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::
197+
198+
use Symfony\Component\Cache\Adapter\RedisAdapter;
199+
use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter;
200+
201+
$client = RedisAdapter::createConnection('redis://localhost');
202+
$cache = new RedisTagAwareAdapter($client);
203+
204+
191205
.. _`Data Source Name (DSN)`: https://en.wikipedia.org/wiki/Data_source_name
192206
.. _`Redis server`: https://redis.io/
193207
.. _`Redis`: https://github.com/phpredis/phpredis

‎components/cache/cache_invalidation.rst

Copy file name to clipboardExpand all lines: components/cache/cache_invalidation.rst
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ 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>` which is optimized for this purpose.
64+
6165
The :class:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapter` class implements
6266
instantaneous invalidation (time complexity is ``O(N)`` where ``N`` is the number
6367
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.