From 24312cb7292bf9f3aceefbf7f8c4ec9c68ee7b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20R?= Date: Wed, 28 Oct 2020 15:37:11 +0100 Subject: [PATCH] [Cache] Adds mention of using FileSystemTagAwareAdatpter --- components/cache/adapters/filesystem_adapter.rst | 13 +++++++++++++ components/cache/cache_invalidation.rst | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/cache/adapters/filesystem_adapter.rst b/components/cache/adapters/filesystem_adapter.rst index 33097fbd202..3939d5f568f 100644 --- a/components/cache/adapters/filesystem_adapter.rst +++ b/components/cache/adapters/filesystem_adapter.rst @@ -55,5 +55,18 @@ and cache root path as constructor parameters:: :ref:`pruning of expired cache items ` by calling its ``prune()`` method. + +.. _filesystem-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 it's often more interesting to use the dedicated :class:`Symfony\\Component\\Cache\\Adapter\\FilesystemTagAwareAdapter`. Since tag invalidation logic is implemented using links on filesystem, this adapter offers better read performance when using tag-based invalidation:: + + use Symfony\Component\Cache\Adapter\FilesystemTagAwareAdapter; + + $cache = new FilesystemTagAwareAdapter(); + + .. _`tmpfs`: https://wiki.archlinux.org/index.php/tmpfs .. _`RAM disk solutions`: https://en.wikipedia.org/wiki/List_of_RAM_drive_software diff --git a/components/cache/cache_invalidation.rst b/components/cache/cache_invalidation.rst index 22f5830cf3e..084cee4cb70 100644 --- a/components/cache/cache_invalidation.rst +++ b/components/cache/cache_invalidation.rst @@ -61,7 +61,8 @@ method. .. note:: When using a Redis backend, consider using :ref:`RedisTagAwareAdapter ` - which is optimized for this purpose. + which is optimized for this purpose. When using File system, likewise consider to use + :ref:`FilesystemTagAwareAdapter `. The :class:`Symfony\\Component\\Cache\\Adapter\\TagAwareAdapter` class implements instantaneous invalidation (time complexity is ``O(N)`` where ``N`` is the number