From 7643bb6fa5a3cebdaa3f120b2d17ae6defcf79de Mon Sep 17 00:00:00 2001 From: iconnor Date: Mon, 15 Jan 2018 11:36:43 -0600 Subject: [PATCH 1/5] Adding documentation. --- plugins/cache.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/cache.rst b/plugins/cache.rst index ea4dfef..120ce3a 100644 --- a/plugins/cache.rst +++ b/plugins/cache.rst @@ -16,9 +16,9 @@ any PSR-6 compatible caching engine. By default, the plugin respects the cache control headers from the server as specified in :rfc:`7234`. It needs a :ref:`stream ` and a `PSR-6`_ implementation:: - use Http\Discovery\HttpClientDiscovery; - use Http\Client\Common\PluginClient; - use Http\Client\Common\Plugin\CachePlugin; + use Http\Discovery\HttpClientDiscovery; use + Http\Client\Common\PluginClient; use + Http\Client\Common\Plugin\CachePlugin; /** @var \Psr\Cache\CacheItemPoolInterface $pool */ $pool = ... @@ -70,6 +70,10 @@ The third parameter to the ``CachePlugin`` constructor takes an array of options | ``cache_key_generator`` | ``new SimpleGenerator()`` | A class implementing ``CacheKeyGenerator`` to generate a PSR-6 cache | | | | key. | +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+ +| ``response_mutator`` | ``null`` | A class implementing ``ResponseMutator`` to mutate a response | +| | | depending if it was from cache or not. | ++---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+ + .. note:: From aba53bb92e4c539f577d35a3c49c7fbf9ae8050c Mon Sep 17 00:00:00 2001 From: iconnor Date: Mon, 15 Jan 2018 11:37:56 -0600 Subject: [PATCH 2/5] Adding documentation. --- plugins/cache.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/cache.rst b/plugins/cache.rst index 120ce3a..cce954e 100644 --- a/plugins/cache.rst +++ b/plugins/cache.rst @@ -16,9 +16,9 @@ any PSR-6 compatible caching engine. By default, the plugin respects the cache control headers from the server as specified in :rfc:`7234`. It needs a :ref:`stream ` and a `PSR-6`_ implementation:: - use Http\Discovery\HttpClientDiscovery; use - Http\Client\Common\PluginClient; use - Http\Client\Common\Plugin\CachePlugin; + use Http\Discovery\HttpClientDiscovery; + use Http\Client\Common\PluginClient; + use Http\Client\Common\Plugin\CachePlugin; /** @var \Psr\Cache\CacheItemPoolInterface $pool */ $pool = ... From 6e6991729e13b967e9d2dcf26654418f928e9455 Mon Sep 17 00:00:00 2001 From: iconnor Date: Tue, 16 Jan 2018 09:14:21 -0600 Subject: [PATCH 3/5] Updating name.: --- plugins/cache.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/cache.rst b/plugins/cache.rst index cce954e..0eb9e2e 100644 --- a/plugins/cache.rst +++ b/plugins/cache.rst @@ -70,8 +70,8 @@ The third parameter to the ``CachePlugin`` constructor takes an array of options | ``cache_key_generator`` | ``new SimpleGenerator()`` | A class implementing ``CacheKeyGenerator`` to generate a PSR-6 cache | | | | key. | +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+ -| ``response_mutator`` | ``null`` | A class implementing ``ResponseMutator`` to mutate a response | -| | | depending if it was from cache or not. | +| ``cache_listeners`` | ``[]]`` | A array of classes implementing ``CacheListener`` to act on a | +| | | response with information on its cache status. | +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+ From 6a233ae4108ba10d18aa2c4280171e3e33976338 Mon Sep 17 00:00:00 2001 From: iconnor Date: Fri, 19 Jan 2018 08:50:39 -0600 Subject: [PATCH 4/5] Adding example. --- plugins/cache.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/cache.rst b/plugins/cache.rst index 0eb9e2e..d72aca9 100644 --- a/plugins/cache.rst +++ b/plugins/cache.rst @@ -70,7 +70,7 @@ The third parameter to the ``CachePlugin`` constructor takes an array of options | ``cache_key_generator`` | ``new SimpleGenerator()`` | A class implementing ``CacheKeyGenerator`` to generate a PSR-6 cache | | | | key. | +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+ -| ``cache_listeners`` | ``[]]`` | A array of classes implementing ``CacheListener`` to act on a | +| ``cache_listeners`` | ``[]`` | A array of classes implementing ``CacheListener`` to act on a | | | | response with information on its cache status. | +---------------------------------------+----------------------------------------------------+-----------------------------------------------------------------------+ @@ -104,6 +104,14 @@ You may define a method how the PSR-6 cache key should be generated. The default is using the request method, URI and body of the request. The cache plugin does also include a ``HeaderCacheKeyGenerator`` which allow you to specify what HTTP header you want include in the cache key. +Controlling cache listeners +``````````````````````````` + +One or more classes ``CacheListener`` can be added through ``cache_listeners``. These classes recieve a notification on +whether a request was a cache hit or miss, and can optionally mutate the response based on those signals. As an example, +adding the provided ``AddHeaderCacheListener`` will mutate the response, adding an ``X-Cache`` header with a value ``HIT`` +or ``MISS``. + Semantics of null values ```````````````````````` From c098173824288a642aabf73e2836bcc3742e2ead Mon Sep 17 00:00:00 2001 From: iconnor Date: Fri, 19 Jan 2018 08:52:39 -0600 Subject: [PATCH 5/5] Adding example. --- plugins/cache.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/cache.rst b/plugins/cache.rst index d72aca9..ed93f9d 100644 --- a/plugins/cache.rst +++ b/plugins/cache.rst @@ -107,10 +107,10 @@ which allow you to specify what HTTP header you want include in the cache key. Controlling cache listeners ``````````````````````````` -One or more classes ``CacheListener`` can be added through ``cache_listeners``. These classes recieve a notification on -whether a request was a cache hit or miss, and can optionally mutate the response based on those signals. As an example, -adding the provided ``AddHeaderCacheListener`` will mutate the response, adding an ``X-Cache`` header with a value ``HIT`` -or ``MISS``. +One or more classes implementing ``CacheListener`` can be added through ``cache_listeners``. These classes recieve a +notification on whether a request was a cache hit or miss, and can optionally mutate the response based on those signals. +As an example, adding the provided ``AddHeaderCacheListener`` will mutate the response, adding an ``X-Cache`` header with +a value ``HIT`` or ``MISS``, which can be useful in debugging. Semantics of null values