Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • CachePlugin
  • CallbackCacheKeyProvider
  • CallbackCanCacheStrategy
  • DefaultCacheKeyProvider
  • DefaultCacheStorage
  • DefaultCanCacheStrategy
  • DefaultRevalidation
  • DenyRevalidation
  • SkipRevalidation

Interfaces

  • CacheKeyProviderInterface
  • CacheStorageInterface
  • CanCacheStrategyInterface
  • RevalidationInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo

Class CachePlugin

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).

Guzzle\Plugin\Cache\CachePlugin implements Symfony\Component\EventDispatcher\EventSubscriberInterface
Namespace: Guzzle\Plugin\Cache
Located at Guzzle/Plugin/Cache/CachePlugin.php
Methods summary
public
# __construct( array|Guzzle\Cache\CacheAdapterInterface|Guzzle\Plugin\Cache\CacheStorageInterface $options = null )

Construct a new CachePlugin. Cache options include the following:

Construct a new CachePlugin. Cache options include the following:

  • CacheKeyProviderInterface key_provider: (optional) Cache key provider
  • CacheAdapterInterface adapter: (optional) Adapter used to cache objects. Pass this or a cache_storage
  • CacheStorageInterface storage: (optional) Adapter used to cache responses
  • RevalidationInterface revalidation: (optional) Cache revalidation strategy
  • CanCacheInterface can_cache: (optional) Object used to determine if a request can be cached
  • int default_ttl: (optional) Default TTL to use when caching if no cache_storage was set must set to 0 or it will assume the default of 3600 secs.
  • bool debug_headers: (optional) Add debug headers to the response (default true)

Parameters

$options
array|Guzzle\Cache\CacheAdapterInterface|Guzzle\Plugin\Cache\CacheStorageInterface
$options Array of options for the cache plugin, cache adapter, or cache storage object.

Throws

Guzzle\Common\Exception\InvalidArgumentException
if no cache is provided and Doctrine cache is not installed
public static array
# getSubscribedEvents( )

Returns an array of event names this subscriber wants to listen to.

Returns an array of event names this subscriber wants to listen to.

Returns

array
The event names to listen to

Implementation of

Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()
public
# onRequestBeforeSend( Guzzle\Common\Event $event )

Check if a response in cache will satisfy the request before sending

Check if a response in cache will satisfy the request before sending

Parameters

$event
Guzzle\Common\Event
$event
public
# onRequestSent( Guzzle\Common\Event $event )

If possible, store a response in cache after sending

If possible, store a response in cache after sending

Parameters

$event
Guzzle\Common\Event
$event
public
# onRequestError( Guzzle\Common\Event $event )

If possible, return a cache response on an error

If possible, return a cache response on an error

Parameters

$event
Guzzle\Common\Event
$event
public null
# onRequestException( Guzzle\Common\Event $event )

If possible, set a cache response on a cURL exception

If possible, set a cache response on a cURL exception

Parameters

$event
Guzzle\Common\Event
$event

Returns

null
public boolean
# canResponseSatisfyRequest( Guzzle\Http\Message\RequestInterface $request, Guzzle\Http\Message\Response $response )

Check if a cache response satisfies a request's caching constraints

Check if a cache response satisfies a request's caching constraints

Parameters

$request
Guzzle\Http\Message\RequestInterface
$request Request to validate
$response
Guzzle\Http\Message\Response
$response Response to validate

Returns

boolean
public boolean
# canResponseSatisfyFailedRequest( Guzzle\Http\Message\RequestInterface $request, Guzzle\Http\Message\Response $response )

Check if a cache response satisfies a failed request's caching constraints

Check if a cache response satisfies a failed request's caching constraints

Parameters

$request
Guzzle\Http\Message\RequestInterface
$request Request to validate
$response
Guzzle\Http\Message\Response
$response Response to validate

Returns

boolean
public
# purge( Guzzle\Http\Message\RequestInterface $request )

Purge a request from the cache storage

Purge a request from the cache storage

Parameters

$request
Guzzle\Http\Message\RequestInterface
$request Request to purge
protected
# addResponseHeaders( string $cacheKey, Guzzle\Http\Message\RequestInterface $request, Guzzle\Http\Message\Response $response )

Add the plugin's headers to a response

Add the plugin's headers to a response

Parameters

$cacheKey
string
$cacheKey Cache key
$request
Guzzle\Http\Message\RequestInterface
$request Request
$response
Guzzle\Http\Message\Response
$response Response to add headers to
Properties summary
protected Guzzle\Plugin\Cache\CacheKeyProviderInterface $keyProvider
#

Cache key provider

Cache key provider

protected Guzzle\Plugin\Cache\RevalidationInterface $revalidation
#

Cache revalidation strategy

Cache revalidation strategy

protected Guzzle\Plugin\Cache\CanCacheStrategyInterface $canCache
#

Object used to determine if a request can be cached

Object used to determine if a request can be cached

protected Guzzle\Plugin\Cache\CacheStorageInterface $storage
#

$cache Object used to cache responses

$cache Object used to cache responses

protected boolean $debugHeaders
#

Whether to add debug headers to the response

Whether to add debug headers to the response

php-coveralls API documentation generated by ApiGen 2.8.0