Skip to content

Commit d3c3709

Browse files
committed
cleanup documenation, keep InvalidateTagCommand BC
1 parent 7df5eb3 commit d3c3709

File tree

5 files changed

+45
-59
lines changed

5 files changed

+45
-59
lines changed

Resources/doc/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
# built documents.
5757
#
5858
# The short X.Y version.
59-
version = '1.0.0'
59+
version = '1.3.0'
6060
# The full version, including alpha/beta/rc tags.
61-
release = '1.0.0'
61+
release = '1.3.0'
6262

6363
# The language for content autogenerated by Sphinx. Refer to documentation
6464
# for a list of supported languages.

Resources/doc/features/tagging.rst

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,51 +38,27 @@ annotations.
3838
Tagging from code
3939
~~~~~~~~~~~~~~~~~
4040

41-
Inject the ``CacheManager`` (service ``fos_http_cache.cache_manager``) and
42-
use ``tagResponse($response, $tags)`` to set tags on a response::
41+
Inject the ``TagHandler`` (service ``fos_http_cache.handler.tag_handler``) and
42+
use ``addTags($tags)`` to add tags that will be set on the response::
4343

44-
use Symfony\Component\HttpFoundation\Response;
45-
use FOS\HttpCacheBundle\CacheManager;
44+
use FOS\HttpCacheBundle\Handler\TagHandler;
4645

4746
class NewsController
4847
{
4948
/**
50-
* @var CacheManager
49+
* @var TagHandler
5150
*/
52-
private $cacheManager;
51+
private $tagHandler;
5352

5453
public function articleAction($id)
5554
{
56-
$response = new Response('Some news article');
57-
$this->cacheManager->tagResponse($response, array('news', 'news-' . $id));
58-
59-
return $response;
60-
}
61-
}
62-
63-
If you have no access to the ``Response`` object (e.g. because it is not
64-
created yet), inject the ``TagSubscriber`` (service ``fos_http_cache.event_listener.tag``)
65-
and call ``addTags($tags)`` to set tags that will be added to the response once
66-
it exists::
67-
68-
use FOS\HttpCacheBundle\EventListener\TagSubscriber;
69-
70-
class Service
71-
{
72-
/**
73-
* @var TagSubscriber
74-
*/
75-
private $tagSubscriber;
76-
77-
public function doStuff($thing)
78-
{
79-
$this->tagSubscriber->addTags(array('news', 'news-' . $thing->getId()));
55+
$this->tagHandler->addTags(array('news', 'news-' . $id));
8056

8157
// ...
8258
}
8359
}
8460

85-
To invalidate tags, call ``CacheManager::invalidateTags($tags)``::
61+
To invalidate tags, call ``TagHandler::invalidateTags($tags)``::
8662

8763
class NewsController
8864
{
@@ -92,13 +68,13 @@ To invalidate tags, call ``CacheManager::invalidateTags($tags)``::
9268
{
9369
// ...
9470

95-
$this->cacheManager->invalidateTags(array('news-' . $id))->flush();
71+
$this->tagHandler->invalidateTags(array('news-' . $id));
9672

9773
// ...
9874
}
9975
}
10076

101-
See the :ref:`Cache Manager reference <cache_manager_tags>` for full details.
77+
See the :ref:`Tag Handler reference <tag_handler_addtags>` for full details.
10278

10379
Configuration
10480
~~~~~~~~~~~~~

Resources/doc/reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ annotations and public methods.
1010
reference/configuration
1111
reference/annotations
1212
reference/cache-manager
13+
reference/tag-handler
1314
reference/glossary

Resources/doc/reference/cache-manager.rst

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,12 @@ Refresh a Route::
8282

8383
.. _cache_manager_tags:
8484

85-
``tagResponse()``
86-
-----------------
85+
``tagResponse()``, ``invalidateTags()``
86+
---------------------------------------
8787

88-
Use the Cache Manager to tag responses::
89-
90-
// $response is a \Symfony\Component\HttpFoundation\Response object
91-
$cacheManager->tagResponse($response, array('some-tag', 'other-tag'));
92-
93-
The tags are appended to already existing tags, unless you set the ``$replace``
94-
option to true::
95-
96-
$cacheManager->tagResponse($response, array('different'), true);
97-
98-
.. tip::
99-
100-
If you do not yet have the response available, you can use the
101-
``TagSubscriber::addTags($tags)`` method to have your tags added once the
102-
response is being sent.
103-
104-
``invalidateTags()``
105-
--------------------
106-
107-
Invalidate cache tags::
108-
109-
$cacheManager->invalidateTags(array('some-tag', 'other-tag'));
88+
..versionadded:: 1.3
89+
Since version 1.3, use the :ref:`TagHandler <tag-handler>` instead of the
90+
CacheManager for working with tags.
11091

11192
.. _flushing:
11293

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
The Tag Handler
2+
===============
3+
4+
Service to work with :doc:`Cache Tagging <../features/tagging>`. You can add tags to the
5+
handler and generate invalidation requests that are queued in the invalidator.
6+
7+
A response listener checks the ``TagHandler`` to detect tags that need to be
8+
set on a response. As with other invalidation operations, invalidation requests
9+
are flushed to the caching proxy :ref:`after the response has been sent <flushing>`.
10+
11+
.. _tag_handler_addtags:
12+
13+
``addTags()``
14+
-------------
15+
16+
Add tags to be sent with the response::
17+
18+
$tagHandler->addTags(array('some-tag', 'other-tag'));
19+
20+
This method can be called regardless of whether the response object already
21+
exists or not.
22+
23+
``invalidateTags()``
24+
--------------------
25+
26+
Invalidate cache tags::
27+
28+
$tagHandler->invalidateTags(array('some-tag', 'other-tag'));

0 commit comments

Comments
 (0)