DefaultCacheStorage
in package
implements
CacheStorageInterface
Default cache storage implementation
Interfaces, Classes and Traits
- CacheStorageInterface
- Interface used to cache HTTP requests
Table of Contents
- $cache : CacheAdapterInterface
- $defaultTtl : int
- $keyPrefix : string
- __construct() : mixed
- cache() : mixed
- Cache an HTTP request
- delete() : mixed
- Deletes cache entries that match a request
- fetch() : null|Response
- Get a Response from the cache for a request
- purge() : mixed
- Purge all cache entries for a given URL
- getBodyKey() : string
- Create a cache key for a response's body
- getCacheKey() : string
- Hash a request URL into a string that returns cache metadata
- persistHeaders() : array<string|int, mixed>
- Creates an array of cacheable and normalized message headers
- requestsMatch() : bool
- Determines whether two Request HTTP header sets are non-varying
Properties
$cache
protected
CacheAdapterInterface
$cache
Cache used to store cache data
$defaultTtl
protected
int
$defaultTtl
Default cache TTL
$keyPrefix
protected
string
$keyPrefix
Methods
__construct()
public
__construct(mixed $cache[, string $keyPrefix = '' ][, int $defaultTtl = 3600 ]) : mixed
Parameters
- $cache : mixed
-
Cache used to store cache data
- $keyPrefix : string = ''
-
Provide an optional key prefix to prefix on all cache keys
- $defaultTtl : int = 3600
-
Default cache TTL
Return values
mixed —cache()
Cache an HTTP request
public
cache(RequestInterface $request, Response $response) : mixed
Parameters
- $request : RequestInterface
-
Request being cached
- $response : Response
-
Response to cache
Return values
mixed —delete()
Deletes cache entries that match a request
public
delete(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface
-
Request to delete from cache
Return values
mixed —fetch()
Get a Response from the cache for a request
public
fetch(RequestInterface $request) : null|Response
Parameters
- $request : RequestInterface
Return values
null|Response —purge()
Purge all cache entries for a given URL
public
purge(mixed $url) : mixed
Parameters
- $url : mixed
Return values
mixed —getBodyKey()
Create a cache key for a response's body
protected
getBodyKey(string $url, EntityBodyInterface $body) : string
Parameters
- $url : string
-
URL of the entry
- $body : EntityBodyInterface
-
Response body
Return values
string —getCacheKey()
Hash a request URL into a string that returns cache metadata
protected
getCacheKey(RequestInterface $request) : string
Parameters
- $request : RequestInterface
Return values
string —persistHeaders()
Creates an array of cacheable and normalized message headers
private
persistHeaders(MessageInterface $message) : array<string|int, mixed>
Parameters
- $message : MessageInterface
Return values
array<string|int, mixed> —requestsMatch()
Determines whether two Request HTTP header sets are non-varying
private
requestsMatch(string $vary, array<string|int, mixed> $r1, array<string|int, mixed> $r2) : bool
Parameters
- $vary : string
-
Response vary header
- $r1 : array<string|int, mixed>
-
HTTP header array
- $r2 : array<string|int, mixed>
-
HTTP header array