Skip to content

Commit 108b770

Browse files
committed
Lots of fixes
1 parent 27de8e0 commit 108b770

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

cache.rst

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Cache
22
=====
33

44
Using cache is a great way of making you application run quicker. The Symfony cache
5-
component is shipped with many adapters to cache storages that all are developed
6-
for high performance.
5+
component is shipped with many adapters to different storages. Every adapter is
6+
developed for high performance.
77

88
Basic uses of the cache looks like this.
99

@@ -16,11 +16,13 @@ Basic uses of the cache looks like this.
1616
$item->expiresAfter(3600);
1717
1818
// Do some HTTP request or heavy computations
19-
$computedValue = ...;
19+
$computedValue = 'foobar';
2020
2121
return $computedValue;
2222
});
2323
24+
echo $value; // 'foobar'
25+
2426
$pool->delete('some_key');
2527
2628
@@ -31,10 +33,11 @@ these at the :ref:`component documentation <component-cache>`.
3133
Configuring Cache with SymfonyFrameworkBundle
3234
---------------------------------------------
3335

34-
When configuring the the cache component there are a few concepts you should know:
36+
When configuring the the cache component there are a few concepts you should know
37+
of:
3538

3639
**Pool**
37-
This is a service that you will interact with. Each pool will always has
40+
This is a service that you will interact with. Each pool will always have
3841
its own namespace and cache items. There is never a conflict between pools.
3942
**Adapter**
4043
An adapter is a *template* that you use to create Pools.
@@ -43,8 +46,8 @@ When configuring the the cache component there are a few concepts you should kno
4346

4447
There are two pools that are always enabled by default. They are ``cache.app`` and
4548
``cache.system``. The system cache is use for things like annotations, serializer,
46-
and validation. The ```cache.app`` is used in your code. You can configure witch
47-
adapters (templates) they use by using the ``app`` and ``system`` key like:
49+
and validation. The ```cache.app`` is used in your code. You can configure which
50+
adapter (template) they use by using the ``app`` and ``system`` key like:
4851

4952
.. code-block:: yaml
5053
@@ -56,17 +59,19 @@ adapters (templates) they use by using the ``app`` and ``system`` key like:
5659
The Cache component comes with a series of adapters already created:
5760

5861
- :ref:`cache.adapter.apcu <component-cache-apcu-adapter>`
59-
- :ref:`cache.adapter.chain <component-cache-chain-adapter>`
62+
- :ref:`ChainAdapter <component-cache-chain-adapter>`
6063
- :ref:`cache.adapter.doctrine <component-cache-doctrine-adapter>`
6164
- :ref:`cache.adapter.filesystem <component-cache-filesystem-adapter>`
6265
- :ref:`cache.adapter.memcached <component-cache-memcached-adapter>`
6366
- :ref:`cache.adapter.pdo <component-cache-pdo-doctrine-dbal-adapter>`
64-
- :ref:`cache.adapter.array <component-cache-php-array-adapter>`
65-
- :ref:`cache.adapter.file <component-cache-php-files-adapter>`
66-
- :ref:`cache.adapter.proxy <component-cache-proxy-adapter>`
67+
- :ref:`PHPArrayAdapter <component-cache-php-array-adapter>`
68+
- :ref:`PHPFileAdapter <component-cache-php-files-adapter>`
69+
- :ref:`ProxyAdapter <component-cache-proxy-adapter>`
6770
- :ref:`cache.adapter.redis <component-cache-redis-adapter>`
6871
- cache.adapter.psr6
6972
- cache.adapter.system
73+
- NullAdapter
74+
- cache.adapter.array
7075

7176
Some of these adapters could be configured via shortcuts:
7277

@@ -83,7 +88,7 @@ Some of these adapters could be configured via shortcuts:
8388
default_pdo_provider: 'doctrine.dbal.default_connection'
8489
8590
Using the *providers* above, they will configure the adapters and create pools (services)
86-
with names:
91+
with service ids:
8792

8893
- ``cache.doctrine``
8994
- ``cache.psr6``
@@ -111,9 +116,9 @@ You can also create more customized pools. All you need is an adapter
111116
provider: 'memcached://user:password@example.com'
112117
113118
The configuration above will create 3 services: ``my_cache_pool``, ``cache.acme``
114-
and ``cache.foobar``. The ``my_cache_pool`` pool is using the :ref:`ArrayAdapter <component-cache-php-array-adapter>`
119+
and ``cache.foobar``. The ``my_cache_pool`` pool is using the ArrayAdapter
115120
and the other two are using the :ref:`MemcachedAdapter <component-cache-memcached-adapter>`.
116-
Pool ``cache.acme`` is using the Memcached server on localhost and ``cache.foobar``
121+
The ``cache.acme`` pool is using the Memcached server on localhost and ``cache.foobar``
117122
is using the Memcached server at example.com.
118123

119124
For advanced configurations it could sometimes be useful to use a pool as an adapter.
@@ -169,12 +174,19 @@ case we have to recalculate the value.
169174
Clearing the Cache
170175
------------------
171176

172-
When the ``bin/console cache:clear`` command is executed it will use
177+
To clear the cache you can use the ``bin/console cache:pool:clear [pool]`` command.
178+
That will remove all the entries from your storage and you wil have to recalcuate
179+
all values. You can also group your pools into "cache clearers". There 3 cache clearer
180+
by default:
181+
182+
* cache.global_clearer
183+
* cache.system_clearer
184+
* cache.app_clearer
173185

174-
Only the system cached is cleared..
186+
The global clearer clears all the cache in every pool. The system cache clearer
187+
is used in the ``bin/console cache:clear`` command. The app clearer is the default
188+
clearer.
175189

176-
cache.system_clearer
177-
cache.default_clearer
178-
cache.app_clearer
190+
.. code-block:: terminal
179191
180-
cache.global_clearer
192+
$ bin/console cache:pool:clear cache.app_clearer

0 commit comments

Comments
 (0)