On this page
Class QueryCacher
Handles caching queries and loading results from the cache.
Used by {@link \Cake\Datasource\QueryTrait} internally.
Property Summary
Method Summary
__construct() public
Constructor.
_resolveCacher() protected
Get the cache engine.
_resolveKey() protected
Get/generate the cache key.
fetch() public
Load the cached results from the cache or run the query.
store() public
Store the result set into the cache.
Method Detail
__construct() public
__construct(Closure|string $key, Psr\SimpleCache\CacheInterface|string $config)
Constructor.
Parameters
Closure|string
$key-
The key or function to generate a key.
Psr\SimpleCache\CacheInterface|string
$config-
The cache config name or cache engine instance.
Throws
RuntimeException
_resolveCacher() protected
_resolveCacher(): Psr\SimpleCache\CacheInterface
Get the cache engine.
Returns
Psr\SimpleCache\CacheInterface
_resolveKey() protected
_resolveKey(object $query): string
Get/generate the cache key.
Parameters
object
$query-
The query to generate a key for.
Returns
string
Throws
RuntimeException
fetch() public
fetch(object $query): mixed|null
Load the cached results from the cache or run the query.
Parameters
object
$query-
The query the cache read is for.
Returns
mixed|null
store() public
store(object $query, Traversable $results): bool
Store the result set into the cache.
Parameters
object
$query-
The query the cache read is for.
Traversable
$results-
The result set to store.
Returns
bool
Property Detail
$_config protected
Config for cache engine.
Type
Psr\SimpleCache\CacheInterface|string
$_key protected
The key or function to generate a key.
Type
Closure|string
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Datasource.QueryCacher.html