diff --git a/cache.rst b/cache.rst index 977ab1e5448..b833ed4bc43 100644 --- a/cache.rst +++ b/cache.rst @@ -4,8 +4,8 @@ Cache ===== -Using cache is a great way of making your application run quicker. The Symfony cache -component is shipped with many adapters to different storages. Every adapter is +Using a cache is a great way of making your application run quicker. The Symfony cache +component ships with many adapters to different storages. Every adapter is developed for high performance. The following example shows a typical usage of the cache:: @@ -27,7 +27,7 @@ The following example shows a typical usage of the cache:: // ... and to remove the cache key $pool->delete('my_cache_key'); -Symfony supports the Cache Contracts, PSR-6/16 and Doctrine Cache interfaces. +Symfony supports Cache Contracts, PSR-6/16 and Doctrine Cache interfaces. You can read more about these at the :doc:`component documentation `. .. versionadded:: 4.2 @@ -46,9 +46,9 @@ of: This is a service that you will interact with. Each pool will always have its own namespace and cache items. There is never a conflict between pools. **Adapter** - An adapter is a *template* that you use to create Pools. + An adapter is a *template* that you use to create pools. **Provider** - A provider is a service that some adapters are using to connect to the storage. + A provider is a service that some adapters use to connect to the storage. Redis and Memcached are example of such adapters. If a DSN is used as the provider then a service is automatically created. @@ -108,7 +108,7 @@ The Cache component comes with a series of adapters pre-configured: * :doc:`cache.adapter.redis ` Some of these adapters could be configured via shortcuts. Using these shortcuts -will create pool with service id of ``cache.[type]`` +will create pools with service IDs that follow the pattern ``cache.[type]``. .. configuration-block:: @@ -302,13 +302,13 @@ You can also create more customized pools: ], ]); -Each pool manages a set of independent cache keys: keys of different pools +Each pool manages a set of independent cache keys: keys from different pools *never* collide, even if they share the same backend. This is achieved by prefixing keys with a namespace that's generated by hashing the name of the pool, the name of the compiled container class and a :ref:`configurable seed` that defaults to the project directory. -Each custom pool becomes a service where the service id is the name of the pool +Each custom pool becomes a service whose service ID is the name of the pool (e.g. ``custom_thing.cache``). An autowiring alias is also created for each pool using the camel case version of its name - e.g. ``custom_thing.cache`` can be injected automatically by naming the argument ``$customThingCache`` and type-hinting it @@ -334,7 +334,7 @@ Custom Provider Options Some providers have specific options that can be configured. The :doc:`RedisAdapter ` allows you to -create providers with option ``timeout``, ``retry_interval``. etc. To use these +create providers with the options ``timeout``, ``retry_interval``. etc. To use these options with non-default values you need to create your own ``\Redis`` provider and use that when configuring the pool. @@ -426,7 +426,7 @@ item in a cache chain, Symfony stores it in all pools sequentially. When retrieving an item, Symfony tries to get it from the first pool. If it's not found, it tries the next pools until the item is found or an exception is thrown. Because of this behavior, it's recommended to define the adapters in the chain -in order from the fastest to the slowest. +in order from fastest to slowest. If an error happens when storing an item in a pool, Symfony stores it in the other pools and no exception is thrown. Later, when the item is retrieved, @@ -494,9 +494,9 @@ Using Cache Tags ---------------- In applications with many cache keys it could be useful to organize the data stored -to be able to invalidate the cache more efficient. One way to achieve that is to +to be able to invalidate the cache more efficiently. One way to achieve that is to use cache tags. One or more tags could be added to the cache item. All items with -the same key could be invalidate with one function call:: +the same key could be invalidated with one function call:: use Symfony\Contracts\Cache\ItemInterface; use Symfony\Contracts\Cache\TagAwareCacheInterface; @@ -644,14 +644,14 @@ Clearing the Cache To clear the cache you can use the ``bin/console cache:pool:clear [pool]`` command. That will remove all the entries from your storage and you will have to recalculate -all values. You can also group your pools into "cache clearers". There are 3 cache +all the values. You can also group your pools into "cache clearers". There are 3 cache clearers by default: * ``cache.global_clearer`` * ``cache.system_clearer`` * ``cache.app_clearer`` -The global clearer clears all the cache in every pool. The system cache clearer +The global clearer clears all the cache items in every pool. The system cache clearer is used in the ``bin/console cache:clear`` command. The app clearer is the default clearer.