@@ -44,42 +44,6 @@ When configuring the cache component there are a few concepts you should know:
4444 Redis and Memcached are examples of such adapters. If a DSN is used as the
4545 provider then a service is automatically created.
4646
47- .. _cache-app-system :
48-
49- There are two pools that are always enabled by default. They are ``cache.app `` and
50- ``cache.system ``. The system cache is used for things like the serializer,
51- and validation. The ``cache.app `` can be used in your code. You can configure which
52- adapter (template) they use by using the ``app `` and ``system `` key like:
53-
54- .. configuration-block ::
55-
56- .. code-block :: yaml
57-
58- # config/packages/cache.yaml
59- framework :
60- cache :
61- app : cache.adapter.filesystem
62- system : cache.adapter.system
63-
64- .. code-block :: php
65-
66- // config/packages/cache.php
67- namespace Symfony\Component\DependencyInjection\Loader\Configurator;
68-
69- return App::config([
70- 'framework' => [
71- 'cache' => [
72- 'app' => 'cache.adapter.filesystem',
73- 'system' => 'cache.adapter.system',
74- ],
75- ],
76- ]);
77-
78- .. tip ::
79-
80- While it is possible to reconfigure the ``system `` cache, it's recommended
81- to keep the default configuration applied to it by Symfony.
82-
8347The Cache component comes with a series of adapters pre-configured:
8448
8549* :doc: `cache.adapter.apcu </components/cache/adapters/apcu_adapter >`
@@ -134,6 +98,69 @@ Some of these adapters could be configured via shortcuts.
13498 ],
13599 ]);
136100
101+ .. _cache-app-system :
102+
103+ System Cache and Application Cache
104+ ----------------------------------
105+
106+ Two cache pools are always enabled by default: ``cache.system `` and ``cache.app ``.
107+
108+ ``cache.system `` is used **internally ** by Symfony components such as annotations,
109+ the serializer, and validation. It is also **available for application ** code,
110+ but only under specific constraints:
111+
112+ #. Entries must be derivable from source code and regeneratable during cache
113+ warmup via a ``CacheWarmer ``.
114+ #. Cached content must only change when the source code changes (i.e. on deployment,
115+ not at runtime); treat it as read-only after deployment.
116+
117+ By default, ``cache.system `` uses ``cache.adapter.system ``, which writes to the
118+ filesystem and chains APCu when available. In most cases, the default is the
119+ right choice.
120+
121+ .. tip ::
122+
123+ While it is possible to reconfigure the ``system `` cache, it's recommended
124+ to keep the default configuration applied to it by Symfony.
125+
126+ ``cache.app `` is a **general-purpose data cache ** for application and bundle code.
127+ Data in this pool does not need to be flushed on deployment. It defaults to
128+ ``cache.adapter.filesystem ``, but configuring a faster adapter like Redis is
129+ recommended when available (this ensures cached data survives deployments and
130+ is shared across multiple instances in a multi-server setup).
131+
132+ :ref: `Custom pools <cache-create-pools >` default to ``cache.app `` as their adapter
133+ unless configured otherwise. When using **autowiring **, ``cache.app `` is injected
134+ automatically into any service argument typed as ``CacheItemPoolInterface ``,
135+ ``AdapterInterface ``, or ``CacheInterface ``.
136+
137+ You can configure the adapter used by each predefined pool via the ``app `` and
138+ ``system `` keys:
139+
140+ .. configuration-block ::
141+
142+ .. code-block :: yaml
143+
144+ # config/packages/cache.yaml
145+ framework :
146+ cache :
147+ app : cache.adapter.filesystem
148+ system : cache.adapter.system
149+
150+ .. code-block :: php
151+
152+ // config/packages/cache.php
153+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
154+
155+ return App::config([
156+ 'framework' => [
157+ 'cache' => [
158+ 'app' => 'cache.adapter.filesystem',
159+ 'system' => 'cache.adapter.system',
160+ ],
161+ ],
162+ ]);
163+
137164 .. _cache-create-pools :
138165
139166Creating Custom (Namespaced) Pools
0 commit comments