Skip to content

Commit c3fc724

Browse files
committed
updated syntax
1 parent ff28d5b commit c3fc724

File tree

1 file changed

+39
-36
lines changed

1 file changed

+39
-36
lines changed

cache.rst

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ Using cache is a great way of making you application run quicker. The Symfony ca
55
component is shipped with many adapters to different storages. Every adapter is
66
developed for high performance.
77

8-
Basic uses of the cache looks like this.
9-
10-
.. code-block:: php
8+
Basic uses of the cache looks like this::
119

1210
use Symfony\Contracts\Cache\ItemInterface;
1311

@@ -27,11 +25,11 @@ Basic uses of the cache looks like this.
2725

2826

2927
Symfony also supports PSR-6 and PSR-16 cache interfaces. You can read more about
30-
these at the :ref:`component documentation <component-cache>`.
28+
these at the :doc:`component documentation </components/cache>`.
3129

3230

33-
Configuring Cache with SymfonyFrameworkBundle
34-
---------------------------------------------
31+
Configuring Cache with FrameworkBundle
32+
--------------------------------------
3533

3634
When configuring the the cache component there are a few concepts you should know
3735
of:
@@ -46,63 +44,65 @@ of:
4644

4745
There are two pools that are always enabled by default. They are ``cache.app`` and
4846
``cache.system``. The system cache is use for things like annotations, serializer,
49-
and validation. The ```cache.app`` is used in your code. You can configure which
47+
and validation. The ``cache.app`` can be used in your code. You can configure which
5048
adapter (template) they use by using the ``app`` and ``system`` key like:
5149

5250
.. code-block:: yaml
5351
52+
# config/packages/cache.yaml
5453
framework:
5554
cache:
5655
app: cache.adapter.filesystem
5756
system: cache.adapter.system
5857
5958
The Cache component comes with a series of adapters already created:
6059

61-
- :ref:`cache.adapter.apcu <component-cache-apcu-adapter>`
62-
- :ref:`ChainAdapter <component-cache-chain-adapter>`
63-
- :ref:`cache.adapter.doctrine <component-cache-doctrine-adapter>`
64-
- :ref:`cache.adapter.filesystem <component-cache-filesystem-adapter>`
65-
- :ref:`cache.adapter.memcached <component-cache-memcached-adapter>`
66-
- :ref:`cache.adapter.pdo <component-cache-pdo-doctrine-dbal-adapter>`
67-
- :ref:`PHPArrayAdapter <component-cache-php-array-adapter>`
68-
- :ref:`PHPFileAdapter <component-cache-php-files-adapter>`
69-
- :ref:`ProxyAdapter <component-cache-proxy-adapter>`
70-
- :ref:`cache.adapter.redis <component-cache-redis-adapter>`
71-
- cache.adapter.psr6
72-
- cache.adapter.system
73-
- NullAdapter
74-
- cache.adapter.array
75-
76-
Some of these adapters could be configured via shortcuts:
60+
* :doc:`cache.adapter.apcu </components/cache/adapters/apcu-adapter>`
61+
* :doc:`cache.adapter.array </components/cache/adapters/array-cache-adapter>`
62+
* :doc:`cache.adapter.doctrine </components/cache/adapters/doctrine-adapter>`
63+
* :doc:`cache.adapter.filesystem </components/cache/adapters/filesystem-adapter>`
64+
* :doc:`cache.adapter.memcached </components/cache/adapters/memcached-adapter>`
65+
* :doc:`cache.adapter.pdo </components/cache/adapters/pdo-doctrine-dbal-adapter>`
66+
* :doc:`cache.adapter.redis </components/cache/adapters/redis-adapter>`
67+
* :doc:`PHPFileAdapter </components/cache/adapters/php-files-adapter>`
68+
* :doc:`PHPArrayAdapter </components/cache/adapters/php-array-adapter>`
69+
70+
* :doc:`ChainAdapter </components/cache/adapters/chain-adapter>`
71+
* :doc:`ProxyAdapter </components/cache/adapters/proxy-adapter>`
72+
* cache.adapter.psr6
73+
74+
* cache.adapter.system
75+
* NullAdapter
76+
77+
Some of these adapters could be configured via shortcuts. Using these shortcuts
78+
will create pool with service id of ``cache.[type]``
7779

7880
.. code-block:: yaml
7981
82+
# config/packages/cache.yaml
8083
framework:
8184
cache:
8285
directory: '%kernel.cache_dir%/pools' # Only used with cache.adapter.filesystem
8386
87+
# service: cache.doctrine
8488
default_doctrine_provider: 'app.doctrine_cache'
89+
# service: cache.psr6
8590
default_psr6_provider: 'app.my_psr6_service'
91+
# service: cache.redis
8692
default_redis_provider: 'redis://localhost'
93+
# service: cache.memcached
8794
default_memcached_provider: 'memcached://localhost'
95+
# service: cache.pdo
8896
default_pdo_provider: 'doctrine.dbal.default_connection'
8997
90-
Using the *providers* above, they will configure the adapters and create pools (services)
91-
with service ids:
92-
93-
- ``cache.doctrine``
94-
- ``cache.psr6``
95-
- ``cache.redis``
96-
- ``cache.memcached``
97-
- ``cache.pdo``
98-
9998
Creating Custom Pools
10099
---------------------
101100

102-
You can also create more customized pools. All you need is an adapter
101+
You can also create more customized pools. All you need is an adapter:
103102

104103
.. code-block:: yaml
105104
105+
# config/packages/cache.yaml
106106
framework:
107107
cache:
108108
default_memcached_provider: 'memcached://localhost'
@@ -117,14 +117,15 @@ You can also create more customized pools. All you need is an adapter
117117
118118
The configuration above will create 3 services: ``my_cache_pool``, ``cache.acme``
119119
and ``cache.foobar``. The ``my_cache_pool`` pool is using the ArrayAdapter
120-
and the other two are using the :ref:`MemcachedAdapter <component-cache-memcached-adapter>`.
120+
and the other two are using the :doc:`MemcachedAdapter </components/cache/adapters/memcached-adapter>`.
121121
The ``cache.acme`` pool is using the Memcached server on localhost and ``cache.foobar``
122122
is using the Memcached server at example.com.
123123

124124
For advanced configurations it could sometimes be useful to use a pool as an adapter.
125125

126126
.. code-block:: yaml
127127
128+
# config/packages/cache.yaml
128129
framework:
129130
cache:
130131
pools:
@@ -145,17 +146,19 @@ Different cache adapters has different strengths and weaknesses. Some might be r
145146
quick but small and some may be able to contain a lot of data but are quite slow.
146147
To get the best of both worlds you may use a chain of adapters. The idea is to
147148
first look at the quick adapter and then move on to slower adapters. In the worst
148-
case we have to recalculate the value.
149+
case the value needs to be recalculated.
149150

150151
.. code-block:: yaml
151152
153+
# config/services.yaml
152154
services:
153155
app.my_cache_chain_adapter:
154156
class: Symfony\Component\Cache\Adapter\ChainAdapter
155157
arguments:
156158
- ['cache.adapter.array', 'cache.my_redis', 'cache.adapter.file']
157159
- 31536000 # One year
158160
161+
# config/packages/cache.yaml
159162
framework:
160163
cache:
161164
pools:
@@ -189,4 +192,4 @@ clearer.
189192

190193
.. code-block:: terminal
191194
192-
$ bin/console cache:pool:clear cache.app_clearer
195+
$ php bin/console cache:pool:clear cache.app_clearer

0 commit comments

Comments
 (0)