Open Monograph Press
3.3.0
|
Public Member Functions | |
__construct ($options=null) | |
canResponseSatisfyFailedRequest (RequestInterface $request, Response $response) | |
canResponseSatisfyRequest (RequestInterface $request, Response $response) | |
onRequestBeforeSend (Event $event) | |
onRequestError (Event $event) | |
onRequestException (Event $event) | |
onRequestSent (Event $event) | |
purge ($url) | |
Static Public Member Functions | |
static | getSubscribedEvents () |
Protected Member Functions | |
addResponseHeaders (RequestInterface $request, Response $response) | |
Protected Attributes | |
$autoPurge | |
$canCache | |
$revalidation | |
$storage | |
Plugin to enable the caching of GET and HEAD requests. Caching can be done on all requests passing through this plugin or only after retrieving resources with cacheable response headers.
This is a simple implementation of RFC 2616 and should be considered a private transparent proxy cache, meaning authorization and private data can be cached.
It also implements RFC 5861's stale-if-error
Cache-Control extension, allowing stale cache responses to be used when an error is encountered (such as a 500 Internal Server Error
or DNS failure).
Definition at line 27 of file CachePlugin.php.
Guzzle\Plugin\Cache\CachePlugin::__construct | ( | $options = null | ) |
array | CacheAdapterInterface | CacheStorageInterface | $options | Array of options for the cache plugin, cache adapter, or cache storage object.
|
InvalidArgumentException | if no cache is provided and Doctrine cache is not installed |
Definition at line 63 of file CachePlugin.php.
References Guzzle\Cache\CacheAdapterFactory\fromCache().
|
protected |
Add the plugin's headers to a response
RequestInterface | $request | Request |
Response | $response | Response to add headers to |
Definition at line 326 of file CachePlugin.php.
References Guzzle\Http\Message\AbstractMessage\addHeader(), Guzzle\Http\Message\AbstractMessage\getHeader(), Guzzle\Http\Message\Response\isFresh(), Guzzle\Http\Message\AbstractMessage\setHeader(), and Guzzle\Common\Version\VERSION.
Referenced by Guzzle\Plugin\Cache\CachePlugin\onRequestError(), Guzzle\Plugin\Cache\CachePlugin\onRequestException(), and Guzzle\Plugin\Cache\CachePlugin\onRequestSent().
Guzzle\Plugin\Cache\CachePlugin::canResponseSatisfyFailedRequest | ( | RequestInterface | $request, |
Response | $response | ||
) |
Check if a cache response satisfies a failed request's caching constraints
RequestInterface | $request | Request to validate |
Response | $response | Response to validate |
Definition at line 286 of file CachePlugin.php.
References Guzzle\Http\Message\Response\getAge(), Guzzle\Http\Message\AbstractMessage\getHeader(), and Guzzle\Http\Message\Response\getMaxAge().
Referenced by Guzzle\Plugin\Cache\CachePlugin\canResponseSatisfyRequest(), Guzzle\Plugin\Cache\CachePlugin\onRequestError(), and Guzzle\Plugin\Cache\CachePlugin\onRequestException().
Guzzle\Plugin\Cache\CachePlugin::canResponseSatisfyRequest | ( | RequestInterface | $request, |
Response | $response | ||
) |
Check if a cache response satisfies a request's caching constraints
RequestInterface | $request | Request to validate |
Response | $response | Response to validate |
Definition at line 240 of file CachePlugin.php.
References Guzzle\Http\Message\Response\calculateAge(), Guzzle\Plugin\Cache\CachePlugin\canResponseSatisfyFailedRequest(), Guzzle\Http\Message\Response\getFreshness(), Guzzle\Http\Message\AbstractMessage\getHeader(), and Guzzle\Http\Message\Response\isFresh().
Referenced by Guzzle\Plugin\Cache\CachePlugin\onRequestBeforeSend().
|
static |
Returns an array of event names this subscriber wants to listen to.
The array keys are event names and the value can be:
For instance:
Implements Symfony\Component\EventDispatcher\EventSubscriberInterface.
Definition at line 100 of file CachePlugin.php.
Referenced by Guzzle\Tests\Plugin\Cache\CachePluginTest\testAddsCallbackCollaborators(), and Guzzle\Tests\Plugin\Cache\CachePluginTest\testAddsDefaultCollaborators().
Guzzle\Plugin\Cache\CachePlugin::onRequestBeforeSend | ( | Event | $event | ) |
Check if a response in cache will satisfy the request before sending
Event | $event |
Definition at line 115 of file CachePlugin.php.
References Guzzle\Plugin\Cache\CachePlugin\canResponseSatisfyRequest(), Guzzle\Plugin\Cache\CachePlugin\purge(), and Guzzle\Common\Version\VERSION.
Guzzle\Plugin\Cache\CachePlugin::onRequestError | ( | Event | $event | ) |
If possible, return a cache response on an error
Event | $event |
Definition at line 179 of file CachePlugin.php.
References Guzzle\Plugin\Cache\CachePlugin\addResponseHeaders(), Guzzle\Plugin\Cache\CachePlugin\canResponseSatisfyFailedRequest(), and Symfony\Component\EventDispatcher\Event\stopPropagation().
Guzzle\Plugin\Cache\CachePlugin::onRequestException | ( | Event | $event | ) |
If possible, set a cache response on a cURL exception
Event | $event |
Definition at line 209 of file CachePlugin.php.
References Guzzle\Plugin\Cache\CachePlugin\addResponseHeaders(), Guzzle\Plugin\Cache\CachePlugin\canResponseSatisfyFailedRequest(), and Symfony\Component\EventDispatcher\Event\stopPropagation().
Guzzle\Plugin\Cache\CachePlugin::onRequestSent | ( | Event | $event | ) |
If possible, store a response in cache after sending
Event | $event |
Definition at line 159 of file CachePlugin.php.
References Guzzle\Plugin\Cache\CachePlugin\addResponseHeaders().
Guzzle\Plugin\Cache\CachePlugin::purge | ( | $url | ) |
Purge all cache entries for a given URL
string | $url | URL to purge |
Definition at line 313 of file CachePlugin.php.
References Guzzle\Http\Message\RequestInterface\getUrl().
Referenced by Guzzle\Plugin\Cache\CachePlugin\onRequestBeforeSend().
|
protected |
Definition at line 51 of file CachePlugin.php.
|
protected |
Object used to determine if a request can be cached
Definition at line 39 of file CachePlugin.php.
|
protected |
Cache revalidation strategy
Definition at line 33 of file CachePlugin.php.
|
protected |
$cache Object used to cache responses
Definition at line 45 of file CachePlugin.php.