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
Cake\Core\Exception\CakeException
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