QueryCacheContext
in package
Holds the query cache policy for the whole running request.
The policy belongs to the request, not to a layer. The admin does not read only through admin
repositories: front managers also run in an admin request (asset, theme, user and auth
managers) and go through a front repository that allows the cache, so a cached record could
still reach an admin screen. BasePresenter therefore disables the
cache once in startup() and that applies to every read made in the request, whichever
repository it uses.
The service is per DI container. The website has a container per request. In a long-running
process (CLI harness, cron) disableForRequest() is never called; if someone calls it,
reset() is the way back, the same pattern as
FieldAudienceContext.
IMPORTANT: the context can only switch the cache off, never on more strongly than the default, so nobody can force a cache on a request that would not otherwise have it.
Table of Contents
Properties
- $enabled : bool
Methods
- disableForRequest() : void
- From this moment to the end of the request every query reads from the database. Called by {@see \App\Core\Base\Admin\BasePresenter::startup()}: one place for the whole admin, so it cannot be forgotten.
- isEnabled() : bool
- reset() : void
- Returns to the default policy (enabled); for long-running processes and tests.
Properties
$enabled
private
bool
$enabled
= true
Methods
disableForRequest()
From this moment to the end of the request every query reads from the database. Called by {@see \App\Core\Base\Admin\BasePresenter::startup()}: one place for the whole admin, so it cannot be forgotten.
public
disableForRequest() : void
isEnabled()
public
isEnabled() : bool
Return values
boolreset()
Returns to the default policy (enabled); for long-running processes and tests.
public
reset() : void