PHP Class Kevinrob\GuzzleCache\CacheMiddleware

Mostrar archivo Open project: kevinrob/guzzle-cache-middleware Class Usage Examples

Protected Properties

Property Type Description
$cacheStorage Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface
$client GuzzleHttp\Client
$httpMethods array List of allowed HTTP methods to cache Key = method name (upscaling) Value = true.
$waitingRevalidate of Promise

Public Methods

Method Description
__construct ( Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface $cacheStrategy = null )
__invoke ( callable $handler ) : callable
getCacheStorage ( ) : Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface
getHttpMethods ( )
getMiddleware ( Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface $cacheStorage = null ) : CacheMiddleware
purgeReValidation ( ) Will be called at the end of the script.
setCacheStorage ( Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface $cacheStorage )
setClient ( Client $client )
setHttpMethods ( array $methods )

Protected Methods

Method Description
addReValidationRequest ( Psr\Http\Message\RequestInterface $request, Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface &$cacheStorage, CacheEntry $cacheEntry ) : boolean
addToCache ( Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface $cache, Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, boolean $update = false ) : Psr\Http\Message\ResponseInterface
getRequestWithReValidationHeader ( Psr\Http\Message\RequestInterface $request, CacheEntry $cacheEntry ) : Psr\Http\Message\RequestInterface
getStaleResponse ( CacheEntry $cacheEntry = null ) : null | Psr\Http\Message\ResponseInterface

Method Details

__construct() public method

public __construct ( Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface $cacheStrategy = null )
$cacheStrategy Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface

__invoke() public method

public __invoke ( callable $handler ) : callable
$handler callable
return callable

addReValidationRequest() protected method

protected addReValidationRequest ( Psr\Http\Message\RequestInterface $request, Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface &$cacheStorage, CacheEntry $cacheEntry ) : boolean
$request Psr\Http\Message\RequestInterface
$cacheStorage Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface
$cacheEntry CacheEntry
return boolean if added

addToCache() protected static method

protected static addToCache ( Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface $cache, Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, boolean $update = false ) : Psr\Http\Message\ResponseInterface
$cache Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface
$request Psr\Http\Message\RequestInterface
$response Psr\Http\Message\ResponseInterface
$update boolean cache
return Psr\Http\Message\ResponseInterface

getCacheStorage() public method

public getCacheStorage ( ) : Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface
return Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface

getHttpMethods() public method

public getHttpMethods ( )

getMiddleware() public static method

Deprecation: Use constructor => `new CacheMiddleware()`
public static getMiddleware ( Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface $cacheStorage = null ) : CacheMiddleware
$cacheStorage Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface
return CacheMiddleware the Middleware for Guzzle HandlerStack

getRequestWithReValidationHeader() protected static method

protected static getRequestWithReValidationHeader ( Psr\Http\Message\RequestInterface $request, CacheEntry $cacheEntry ) : Psr\Http\Message\RequestInterface
$request Psr\Http\Message\RequestInterface
$cacheEntry CacheEntry
return Psr\Http\Message\RequestInterface

getStaleResponse() protected static method

protected static getStaleResponse ( CacheEntry $cacheEntry = null ) : null | Psr\Http\Message\ResponseInterface
$cacheEntry CacheEntry
return null | Psr\Http\Message\ResponseInterface

purgeReValidation() public method

Will be called at the end of the script.
public purgeReValidation ( )

setCacheStorage() public method

public setCacheStorage ( Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface $cacheStorage )
$cacheStorage Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface

setClient() public method

public setClient ( Client $client )
$client GuzzleHttp\Client

setHttpMethods() public method

public setHttpMethods ( array $methods )
$methods array

Property Details

$cacheStorage protected_oe property

protected CacheStrategyInterface,Kevinrob\GuzzleCache\Strategy $cacheStorage
return Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface

$client protected_oe property

protected Client,GuzzleHttp $client
return GuzzleHttp\Client

$httpMethods protected_oe property

List of allowed HTTP methods to cache Key = method name (upscaling) Value = true.
protected array $httpMethods
return array

$waitingRevalidate protected_oe property

of Promise
protected $waitingRevalidate