FileAccess Orion

HttpCache extends HttpCache
in package

Manages HTTP cache objects in a Container.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

$cacheDir  : mixed
$kernel  : mixed
$options  : mixed
$request  : mixed
$store  : mixed
$surrogate  : mixed
$surrogateCacheStrategy  : mixed
$traces  : mixed
__construct()  : mixed
Constructor.
getKernel()  : HttpKernelInterface
Gets the Kernel instance.
getLog()  : string
Returns a log message for the events of the last request processing.
getRequest()  : Request
Gets the Request instance associated with the master request.
getStore()  : StoreInterface
Gets the current store.
getSurrogate()  : SurrogateInterface
Gets the Surrogate instance.
getTraces()  : array<string|int, mixed>
Returns an array of events that took place during processing of the last request.
handle()  : Response
Handles a Request to convert it to a Response.
terminate()  : mixed
Terminates a request/response cycle.
createStore()  : mixed
createSurrogate()  : mixed
fetch()  : Response
Unconditionally fetches a fresh response from the backend and stores it in the cache if is cacheable.
forward()  : Response
Forwards the Request to the backend and returns the Response.
getOptions()  : array<string|int, mixed>
Returns an array of options to customize the Cache configuration.
invalidate()  : Response
Invalidates non-safe methods (like POST, PUT, and DELETE).
isFreshEnough()  : bool
Checks whether the cache entry is "fresh enough" to satisfy the Request.
lock()  : bool
Locks a Request during the call to the backend.
lookup()  : Response
Lookups a Response from the cache for the given Request.
pass()  : Response
Forwards the Request to the backend without storing the Response in the cache.
processResponseBody()  : mixed
store()  : mixed
Writes the Response to the cache.
validate()  : Response
Validates that a cache entry is fresh.
addTraces()  : mixed
getTraceKey()  : string
Calculates the key we use in the "trace" array for a given request.
isPrivateRequest()  : bool
Checks if the Request includes authorization or other sensitive information that should cause the Response to be considered private by default.
mayServeStaleWhileRevalidate()  : bool
Checks whether the given (cached) response may be served as "stale" when a revalidation is currently in progress.
record()  : mixed
Records that an event took place.
restoreResponseBody()  : mixed
Restores the Response body.
waitForLock()  : bool
Waits for the store to release a locked entry.

Properties

$surrogateCacheStrategy

private mixed $surrogateCacheStrategy

Methods

__construct()

Constructor.

public __construct(KernelInterface $kernel[, string $cacheDir = null ]) : mixed
Parameters
$kernel : KernelInterface
$cacheDir : string = null

The cache directory (default used if null)

Return values
mixed

getLog()

Returns a log message for the events of the last request processing.

public getLog() : string
Return values
string

A log message

getRequest()

Gets the Request instance associated with the master request.

public getRequest() : Request
Return values
Request

A Request instance

getTraces()

Returns an array of events that took place during processing of the last request.

public getTraces() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of events

handle()

Handles a Request to convert it to a Response.

public handle(Request $request[, mixed $type = HttpKernelInterface::MASTER_REQUEST ][, mixed $catch = true ]) : Response
Parameters
$request : Request
$type : mixed = HttpKernelInterface::MASTER_REQUEST

The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)

$catch : mixed = true

Whether to catch exceptions or not

Return values
Response

A Response instance

createStore()

protected createStore() : mixed
Return values
mixed

createSurrogate()

protected createSurrogate() : mixed
Return values
mixed

fetch()

Unconditionally fetches a fresh response from the backend and stores it in the cache if is cacheable.

protected fetch(Request $request[, bool $catch = false ]) : Response
Parameters
$request : Request
$catch : bool = false

Whether to process exceptions

Return values
Response

A Response instance

forward()

Forwards the Request to the backend and returns the Response.

protected forward(Request $request[, bool $raw = false ][, Response $entry = null ]) : Response
Parameters
$request : Request
$raw : bool = false

Whether to catch exceptions or not

$entry : Response = null

A Response instance (the stale entry if present, null otherwise)

Return values
Response

A Response instance

getOptions()

Returns an array of options to customize the Cache configuration.

protected getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of options

invalidate()

Invalidates non-safe methods (like POST, PUT, and DELETE).

protected invalidate(Request $request[, bool $catch = false ]) : Response
Parameters
$request : Request
$catch : bool = false

Whether to process exceptions

Tags
throws
Exception
see
RFC2616

13.10

Return values
Response

A Response instance

isFreshEnough()

Checks whether the cache entry is "fresh enough" to satisfy the Request.

protected isFreshEnough(Request $request, Response $entry) : bool
Parameters
$request : Request
$entry : Response
Return values
bool

true if the cache entry if fresh enough, false otherwise

lock()

Locks a Request during the call to the backend.

protected lock(Request $request, Response $entry) : bool
Parameters
$request : Request
$entry : Response
Return values
bool

true if the cache entry can be returned even if it is staled, false otherwise

lookup()

Lookups a Response from the cache for the given Request.

protected lookup(Request $request[, bool $catch = false ]) : Response

When a matching cache entry is found and is fresh, it uses it as the response without forwarding any request to the backend. When a matching cache entry is found but is stale, it attempts to "validate" the entry with the backend using conditional GET. When no matching cache entry is found, it triggers "miss" processing.

Parameters
$request : Request
$catch : bool = false

Whether to process exceptions

Tags
throws
Exception
Return values
Response

A Response instance

pass()

Forwards the Request to the backend without storing the Response in the cache.

protected pass(Request $request[, bool $catch = false ]) : Response
Parameters
$request : Request
$catch : bool = false

Whether to process exceptions

Return values
Response

A Response instance

store()

Writes the Response to the cache.

protected store(Request $request, Response $response) : mixed
Parameters
$request : Request
$response : Response
Tags
throws
Exception
Return values
mixed

validate()

Validates that a cache entry is fresh.

protected validate(Request $request, Response $entry[, bool $catch = false ]) : Response

The original request is used as a template for a conditional GET request with the backend.

Parameters
$request : Request
$entry : Response
$catch : bool = false

Whether to process exceptions

Return values
Response

A Response instance

getTraceKey()

Calculates the key we use in the "trace" array for a given request.

private getTraceKey(Request $request) : string
Parameters
$request : Request
Return values
string

isPrivateRequest()

Checks if the Request includes authorization or other sensitive information that should cause the Response to be considered private by default.

private isPrivateRequest(Request $request) : bool
Parameters
$request : Request
Return values
bool

mayServeStaleWhileRevalidate()

Checks whether the given (cached) response may be served as "stale" when a revalidation is currently in progress.

private mayServeStaleWhileRevalidate(Response $entry) : bool
Parameters
$entry : Response
Return values
bool

record()

Records that an event took place.

private record(Request $request, string $event) : mixed
Parameters
$request : Request
$event : string
Return values
mixed

restoreResponseBody()

Restores the Response body.

private restoreResponseBody(Request $request, Response $response) : mixed
Parameters
$request : Request
$response : Response
Return values
mixed

waitForLock()

Waits for the store to release a locked entry.

private waitForLock(Request $request) : bool
Parameters
$request : Request
Return values
bool

Search results