PHP Класс Symfony\Component\HttpKernel\HttpCache\HttpCache

Автор: Fabien Potencier ([email protected])
Наследование: implements Symfony\Component\HttpKernel\HttpKernelInterface
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( Symfony\Component\HttpKernel\HttpKernelInterface $kernel, Symfony\Component\HttpKernel\HttpCache\StoreInterface $store, Symfony\Component\HttpKernel\HttpCache\SurrogateInterface $surrogate = null, array $options = [] ) Constructor.
getKernel ( ) : Symfony\Component\HttpKernel\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 ( ) : Symfony\Component\HttpKernel\HttpCache\StoreInterface Gets the current store.
getSurrogate ( ) : Symfony\Component\HttpKernel\HttpCache\SurrogateInterface Gets the Surrogate instance.
getTraces ( ) : array Returns an array of events that took place during processing of the last request.
handle ( Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true )
terminate ( Request $request, Response $response )

Защищенные методы

Метод Описание
fetch ( Request $request, boolean $catch = false ) : Response Forwards the Request to the backend and determines whether the response should be stored.
forward ( Request $request, boolean $catch = false, Response $entry = null ) : Response Forwards the Request to the backend and returns the Response.
invalidate ( Request $request, boolean $catch = false ) : Response Invalidates non-safe methods (like POST, PUT, and DELETE).
isFreshEnough ( Request $request, Response $entry ) : boolean Checks whether the cache entry is "fresh enough" to satisfy the Request.
lock ( Request $request, Response $entry ) : boolean Locks a Request during the call to the backend.
lookup ( Request $request, boolean $catch = false ) : Response Lookups a Response from the cache for the given Request.
pass ( Request $request, boolean $catch = false ) : Response Forwards the Request to the backend without storing the Response in the cache.
processResponseBody ( Request $request, Response $response )
store ( Request $request, Response $response ) Writes the Response to the cache.
validate ( Request $request, Response $entry, boolean $catch = false ) : Response Validates that a cache entry is fresh.

Приватные методы

Метод Описание
isPrivateRequest ( Request $request ) : boolean Checks if the Request includes authorization or other sensitive information that should cause the Response to be considered private by default.
record ( Request $request, string $event ) Records that an event took place.
restoreResponseBody ( Request $request, Response $response ) Restores the Response body.

Описание методов

__construct() публичный Метод

The available options are: * debug: If true, the traces are added as a HTTP header to ease debugging * default_ttl The number of seconds that a cache entry should be considered fresh when no explicit freshness information is provided in a response. Explicit Cache-Control or Expires headers override this value. (default: 0) * private_headers Set of request headers that trigger "private" cache-control behavior on responses that don't explicitly state whether the response is public or private via a Cache-Control directive. (default: Authorization and Cookie) * allow_reload Specifies whether the client can force a cache reload by including a Cache-Control "no-cache" directive in the request. Set it to true for compliance with RFC 2616. (default: false) * allow_revalidate Specifies whether the client can force a cache revalidate by including a Cache-Control "max-age=0" directive in the request. Set it to true for compliance with RFC 2616. (default: false) * stale_while_revalidate Specifies the default number of seconds (the granularity is the second as the Response TTL precision is a second) during which the cache can immediately return a stale response while it revalidates it in the background (default: 2). This setting is overridden by the stale-while-revalidate HTTP Cache-Control extension (see RFC 5861). * stale_if_error Specifies the default number of seconds (the granularity is the second) during which the cache can serve a stale response when an error is encountered (default: 60). This setting is overridden by the stale-if-error HTTP Cache-Control extension (see RFC 5861).
public __construct ( Symfony\Component\HttpKernel\HttpKernelInterface $kernel, Symfony\Component\HttpKernel\HttpCache\StoreInterface $store, Symfony\Component\HttpKernel\HttpCache\SurrogateInterface $surrogate = null, array $options = [] )
$kernel Symfony\Component\HttpKernel\HttpKernelInterface An HttpKernelInterface instance
$store Symfony\Component\HttpKernel\HttpCache\StoreInterface A Store instance
$surrogate Symfony\Component\HttpKernel\HttpCache\SurrogateInterface A SurrogateInterface instance
$options array An array of options

fetch() защищенный Метод

This methods is triggered when the cache missed or a reload is required.
protected fetch ( Request $request, boolean $catch = false ) : Response
$request Symfony\Component\HttpFoundation\Request A Request instance
$catch boolean whether to process exceptions
Результат Symfony\Component\HttpFoundation\Response A Response instance

forward() защищенный Метод

Forwards the Request to the backend and returns the Response.
protected forward ( Request $request, boolean $catch = false, Response $entry = null ) : Response
$request Symfony\Component\HttpFoundation\Request A Request instance
$catch boolean Whether to catch exceptions or not
$entry Symfony\Component\HttpFoundation\Response A Response instance (the stale entry if present, null otherwise)
Результат Symfony\Component\HttpFoundation\Response A Response instance

getKernel() публичный Метод

Gets the Kernel instance.
public getKernel ( ) : Symfony\Component\HttpKernel\HttpKernelInterface
Результат Symfony\Component\HttpKernel\HttpKernelInterface An HttpKernelInterface instance

getLog() публичный Метод

Returns a log message for the events of the last request processing.
public getLog ( ) : string
Результат string A log message

getRequest() публичный Метод

Gets the Request instance associated with the master request.
public getRequest ( ) : Request
Результат Symfony\Component\HttpFoundation\Request A Request instance

getStore() публичный Метод

Gets the current store.
public getStore ( ) : Symfony\Component\HttpKernel\HttpCache\StoreInterface
Результат Symfony\Component\HttpKernel\HttpCache\StoreInterface $store A StoreInterface instance

getSurrogate() публичный Метод

Gets the Surrogate instance.
public getSurrogate ( ) : Symfony\Component\HttpKernel\HttpCache\SurrogateInterface
Результат Symfony\Component\HttpKernel\HttpCache\SurrogateInterface A Surrogate instance

getTraces() публичный Метод

Returns an array of events that took place during processing of the last request.
public getTraces ( ) : array
Результат array An array of events

handle() публичный Метод

public handle ( Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true )
$request Symfony\Component\HttpFoundation\Request

invalidate() защищенный Метод

Invalidates non-safe methods (like POST, PUT, and DELETE).
См. также: RFC2616 13.10
protected invalidate ( Request $request, boolean $catch = false ) : Response
$request Symfony\Component\HttpFoundation\Request A Request instance
$catch boolean Whether to process exceptions
Результат Symfony\Component\HttpFoundation\Response A Response instance

isFreshEnough() защищенный Метод

Checks whether the cache entry is "fresh enough" to satisfy the Request.
protected isFreshEnough ( Request $request, Response $entry ) : boolean
$request Symfony\Component\HttpFoundation\Request A Request instance
$entry Symfony\Component\HttpFoundation\Response A Response instance
Результат boolean 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 ) : boolean
$request Symfony\Component\HttpFoundation\Request A Request instance
$entry Symfony\Component\HttpFoundation\Response A Response instance
Результат boolean true if the cache entry can be returned even if it is staled, false otherwise

lookup() защищенный Метод

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.
protected lookup ( Request $request, boolean $catch = false ) : Response
$request Symfony\Component\HttpFoundation\Request A Request instance
$catch boolean whether to process exceptions
Результат Symfony\Component\HttpFoundation\Response A Response instance

pass() защищенный Метод

Forwards the Request to the backend without storing the Response in the cache.
protected pass ( Request $request, boolean $catch = false ) : Response
$request Symfony\Component\HttpFoundation\Request A Request instance
$catch boolean Whether to process exceptions
Результат Symfony\Component\HttpFoundation\Response A Response instance

processResponseBody() защищенный Метод

protected processResponseBody ( Request $request, Response $response )
$request Symfony\Component\HttpFoundation\Request
$response Symfony\Component\HttpFoundation\Response

store() защищенный Метод

Writes the Response to the cache.
protected store ( Request $request, Response $response )
$request Symfony\Component\HttpFoundation\Request A Request instance
$response Symfony\Component\HttpFoundation\Response A Response instance

terminate() публичный Метод

public terminate ( Request $request, Response $response )
$request Symfony\Component\HttpFoundation\Request
$response Symfony\Component\HttpFoundation\Response

validate() защищенный Метод

The original request is used as a template for a conditional GET request with the backend.
protected validate ( Request $request, Response $entry, boolean $catch = false ) : Response
$request Symfony\Component\HttpFoundation\Request A Request instance
$entry Symfony\Component\HttpFoundation\Response A Response instance to validate
$catch boolean Whether to process exceptions
Результат Symfony\Component\HttpFoundation\Response A Response instance