PHP Class Kevinrob\GuzzleCache\Strategy\PrivateCacheStrategy
Pay attention to share storage between application with caution!
For example, a response with cache-control header "private, max-age=60"
will be cached by this strategy.
The rules applied are from RFC 7234.
Show file
Open project: kevinrob/guzzle-cache-middleware
Class Usage Examples
Protected Properties
Public Methods
Method |
Description |
|
__construct ( Kevinrob\GuzzleCache\Storage\CacheStorageInterface $cache = null ) |
|
|
cache ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response ) : boolean |
|
|
fetch ( Psr\Http\Message\RequestInterface $request ) : CacheEntry | null |
Return a CacheEntry or null if no cache. |
|
update ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response ) : boolean |
|
|
Protected Methods
Method |
Description |
|
getCacheKey ( Psr\Http\Message\RequestInterface $request ) : string |
|
|
getCacheObject ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response ) : CacheEntry | null |
|
|
Method Details
__construct()
public method
public __construct ( Kevinrob\GuzzleCache\Storage\CacheStorageInterface $cache = null ) |
$cache |
Kevinrob\GuzzleCache\Storage\CacheStorageInterface |
|
public cache ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response ) : boolean |
$request |
Psr\Http\Message\RequestInterface |
|
$response |
Psr\Http\Message\ResponseInterface |
|
return |
boolean |
true if success |
Return a CacheEntry or null if no cache.
public fetch ( Psr\Http\Message\RequestInterface $request ) : CacheEntry | null |
$request |
Psr\Http\Message\RequestInterface |
|
return |
Kevinrob\GuzzleCache\CacheEntry | null |
|
getCacheKey()
protected method
protected getCacheKey ( Psr\Http\Message\RequestInterface $request ) : string |
$request |
Psr\Http\Message\RequestInterface |
|
return |
string |
|
getCacheObject()
protected method
protected getCacheObject ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response ) : CacheEntry | null |
$request |
Psr\Http\Message\RequestInterface |
|
$response |
Psr\Http\Message\ResponseInterface |
|
return |
Kevinrob\GuzzleCache\CacheEntry | null |
entry to save, null if can't cache it |
public update ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response ) : boolean |
$request |
Psr\Http\Message\RequestInterface |
|
$response |
Psr\Http\Message\ResponseInterface |
|
return |
boolean |
true if success |
Property Details
$ageKey protected property
protected string[] $ageKey |
return |
string[] |
|
$statusAccepted protected property
protected int[] $statusAccepted |
return |
int[] |
|
$storage protected property
protected CacheStorageInterface,Kevinrob\GuzzleCache\Storage $storage |
return |
Kevinrob\GuzzleCache\Storage\CacheStorageInterface |
|