class Store implements StoreInterface

Store implements all the logic for storing cache metadata (Request and Response headers).

Properties

protected $root

Methods

__construct(string $root)

No description

cleanup()

Cleanups storage.

bool|string
lock(Request $request)

Tries to lock the cache for a given Request, without blocking.

bool
unlock(Request $request)

Releases the lock for the given Request.

bool
isLocked(Request $request)

Returns whether or not a lock exists.

Response|null
lookup(Request $request)

Locates a cached Response for the Request provided.

string
write(Request $request, Response $response)

Writes a cache entry to the store for the given Request and Response.

string
generateContentDigest(Response $response)

Returns content digest for $response.

invalidate(Request $request)

Invalidates all cache entries that match the request.

bool
purge(string $url)

Purges data for the given URL.

getPath($key)

No description

string
generateCacheKey(Request $request)

Generates a cache key for the given Request.

Details

at line 34
__construct(string $root)

Parameters

string $root

Exceptions

RuntimeException

at line 47
cleanup()

Cleanups storage.

at line 63
bool|string lock(Request $request)

Tries to lock the cache for a given Request, without blocking.

Parameters

Request $request

Return Value

bool|string true if the lock is acquired, the path to the current lock otherwise

at line 90
bool unlock(Request $request)

Releases the lock for the given Request.

Parameters

Request $request

Return Value

bool False if the lock file does not exist or cannot be unlocked, true otherwise

at line 105
bool isLocked(Request $request)

Returns whether or not a lock exists.

Parameters

Request $request

Return Value

bool true if lock exists, false otherwise

at line 130
Response|null lookup(Request $request)

Locates a cached Response for the Request provided.

Parameters

Request $request

Return Value

Response|null A Response instance, or null if no cache entry was found

at line 172
string write(Request $request, Response $response)

Writes a cache entry to the store for the given Request and Response.

Existing entries are read and any that match the response are removed. This method calls write with the new list of cache entries.

Parameters

Request $request
Response $response

Return Value

string The key under which the response is stored

Exceptions

RuntimeException

at line 222
protected string generateContentDigest(Response $response)

Returns content digest for $response.

Parameters

Response $response

Return Value

string

at line 232
invalidate(Request $request)

Invalidates all cache entries that match the request.

Parameters

Request $request

Exceptions

RuntimeException

at line 309
bool purge(string $url)

Purges data for the given URL.

This method purges both the HTTP and the HTTPS version of the cache entry.

Parameters

string $url A URL

Return Value

bool true if the URL exists and has been purged, false otherwise

at line 411
getPath($key)

Parameters

$key

at line 428
protected string generateCacheKey(Request $request)

Generates a cache key for the given Request.

This method should return a key that must only depend on a normalized version of the request URI.

If the same URI can have more than one representation, based on some headers, use a Vary header to indicate them, and each representation will be stored independently under the same cache key.

Parameters

Request $request

Return Value

string A key for the given Request