Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
Kevinrob\GuzzleCache\CacheMiddleware Class Reference

Public Member Functions

 __construct (CacheStrategyInterface $cacheStrategy=null)
 
 __invoke (callable $handler)
 
 getCacheStorage ()
 
 getHttpMethods ()
 
 purgeReValidation ()
 Will be called at the end of the script.
 
 setCacheStorage (CacheStrategyInterface $cacheStorage)
 
 setClient (Client $client)
 
 setHttpMethods (array $methods)
 

Static Public Member Functions

static getMiddleware (CacheStrategyInterface $cacheStorage=null)
 

Public Attributes

const HEADER_CACHE_HIT = 'HIT'
 
const HEADER_CACHE_INFO = 'X-Kevinrob-Cache'
 
const HEADER_CACHE_MISS = 'MISS'
 
const HEADER_CACHE_STALE = 'STALE'
 
const HEADER_INVALIDATION = 'X-Kevinrob-GuzzleCache-Invalidation'
 
const HEADER_RE_VALIDATION = 'X-Kevinrob-GuzzleCache-ReValidation'
 

Protected Member Functions

 addReValidationRequest (RequestInterface $request, CacheStrategyInterface &$cacheStorage, CacheEntry $cacheEntry)
 

Static Protected Member Functions

static addToCache (CacheStrategyInterface $cache, RequestInterface $request, ResponseInterface $response, $update=false)
 
static getRequestWithReValidationHeader (RequestInterface $request, CacheEntry $cacheEntry)
 
static getStaleResponse (CacheEntry $cacheEntry=null)
 

Protected Attributes

CacheStrategyInterface $cacheStorage
 
Client $client
 
array $httpMethods = ['GET' => true]
 List of allowed HTTP methods to cache Key = method name (upscaling) Value = true.
 
array $safeMethods = ['GET' => true, 'HEAD' => true, 'OPTIONS' => true, 'TRACE' => true]
 List of safe methods.
 
array $waitingRevalidate = []
 of Promise
 

Constructor & Destructor Documentation

◆ __construct()

Kevinrob\GuzzleCache\CacheMiddleware::__construct ( CacheStrategyInterface $cacheStrategy = null)
Parameters
CacheStrategyInterface | null$cacheStrategy

Member Function Documentation

◆ __invoke()

Kevinrob\GuzzleCache\CacheMiddleware::__invoke ( callable $handler)
Parameters
callable$handler
Return values
callable

◆ addReValidationRequest()

Kevinrob\GuzzleCache\CacheMiddleware::addReValidationRequest ( RequestInterface $request,
CacheStrategyInterface & $cacheStorage,
CacheEntry $cacheEntry )
protected
Parameters
RequestInterface$request
CacheStrategyInterface$cacheStorage
CacheEntry$cacheEntry
Return values
boolif added

◆ addToCache()

static Kevinrob\GuzzleCache\CacheMiddleware::addToCache ( CacheStrategyInterface $cache,
RequestInterface $request,
ResponseInterface $response,
$update = false )
staticprotected
Parameters
CacheStrategyInterface$cache
RequestInterface$request
ResponseInterface$response
bool$updatecache
Return values
ResponseInterface

◆ getCacheStorage()

Kevinrob\GuzzleCache\CacheMiddleware::getCacheStorage ( )
Return values
CacheStrategyInterface

◆ getMiddleware()

static Kevinrob\GuzzleCache\CacheMiddleware::getMiddleware ( CacheStrategyInterface $cacheStorage = null)
static
Parameters
CacheStrategyInterface | null$cacheStorage
Return values
CacheMiddlewarethe Middleware for Guzzle HandlerStack
Deprecated
Use constructor => new CacheMiddleware()

◆ getRequestWithReValidationHeader()

static Kevinrob\GuzzleCache\CacheMiddleware::getRequestWithReValidationHeader ( RequestInterface $request,
CacheEntry $cacheEntry )
staticprotected
Parameters
RequestInterface$request
CacheEntry$cacheEntry
Return values
RequestInterface

◆ getStaleResponse()

static Kevinrob\GuzzleCache\CacheMiddleware::getStaleResponse ( CacheEntry $cacheEntry = null)
staticprotected
Parameters
CacheEntry | null$cacheEntry
Return values
null|ResponseInterface

◆ setCacheStorage()

Kevinrob\GuzzleCache\CacheMiddleware::setCacheStorage ( CacheStrategyInterface $cacheStorage)
Parameters
CacheStrategyInterface$cacheStorage

◆ setClient()

Kevinrob\GuzzleCache\CacheMiddleware::setClient ( Client $client)
Parameters
Client$client

◆ setHttpMethods()

Kevinrob\GuzzleCache\CacheMiddleware::setHttpMethods ( array $methods)
Parameters
array$methods

Member Data Documentation

◆ $safeMethods

array Kevinrob\GuzzleCache\CacheMiddleware::$safeMethods = ['GET' => true, 'HEAD' => true, 'OPTIONS' => true, 'TRACE' => true]
protected

The documentation for this class was generated from the following file: