@@ -10,20 +10,22 @@ change in the state of your model. The most basic kind of invalidation is direct
1010items deletion. But when the state of a primary resource has spread accross
1111several cached items, keeping them in sync can be difficult.
1212
13- The Symfony Cache component provides two mechanisms to help solve this problem:
13+ The Symfony Cache component provides two mechanisms to help solving this problem:
1414
15- * Tags based invalidation for managing data dependencies;
16- * Expiration based invalidation for time related dependencies.
15+ * :ref: ` Tags based invalidation < cache-component-tags >` for managing data dependencies;
16+ * :ref: ` Expiration based invalidation < cache-component-expiration >` for time related dependencies.
1717
18- .. versionadded :: 3.2
19- Tags based invalidation was introduced in Symfony 3.2.
18+ .. _cache-component-tags :
2019
2120Using Cache Tags
2221----------------
2322
23+ .. versionadded :: 3.2
24+ Tags based invalidation was introduced in Symfony 3.2.
25+
2426To benefit from tags based invalidation, you need to attach the proper tags to
25- each cached items . Each tag is a plain string identifier that you can use at any
26- time to trigger the removal of all items that had this tag attached to them .
27+ each cached item . Each tag is a plain string identifier that you can use at any
28+ time to trigger the removal of all items associated with this tag.
2729
2830To attach tags to cached items, you need to use the
2931:method: `Symfony\\ Component\\ Cache\\ CacheItem::tag ` method that is implemented by
@@ -36,14 +38,14 @@ cache items, as returned by cache adapters::
3638 $item->tag(array('tag_2', 'tag_3'));
3739 $cache->save($item);
3840
39- If ``$cache `` implements :class: `Symfony\\ Component\\ Cache\\ TagAwareAdapterInterface `,
41+ If ``$cache `` implements :class: `Symfony\\ Component\\ Cache\\ Adapter \\ TagAwareAdapterInterface `,
4042you can invalidate the cached items by calling
41- :method: `Symfony\\ Component\\ Cache\\ TagAwareAdapterInterface::invalidateTags `::
43+ :method: `Symfony\\ Component\\ Cache\\ Adapter \\ TagAwareAdapterInterface::invalidateTags `::
4244
4345 // invalidate all items related to `tag_1` or `tag_3`
4446 $cache->invalidateTags(array('tag_1', 'tag_3'));
4547
46- // if you know the cache key, you can of course delete directly
48+ // if you know the cache key, you can also delete the item directly
4749 $cache->deleteItem('cache_key');
4850
4951Using tags invalidation is very useful when tracking cache keys becomes difficult.
@@ -78,6 +80,8 @@ your fronts and have very fast invalidation checks::
7880 new RedisAdapter('redis://localhost')
7981 );
8082
83+ .. _cache-component-expiration :
84+
8185Using Cache Expiration
8286----------------------
8387
0 commit comments