Class QueryCacher
Handles caching queries and loading results from the cache.
Used by Cake\Datasource\QueryTrait internally.
Namespace: Cake\Datasource
See: \Cake\Datasource\QueryTrait::cache() for the public interface.
Location: Datasource/QueryCacher.php
See: \Cake\Datasource\QueryTrait::cache() for the public interface.
Location: Datasource/QueryCacher.php
Properties summary
-
$_config
protectedstring|
Cake\Cache\CacheEngine
Config for cache engine. -
$_key
protectedstring|callable
The key or function to generate a key.
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( string|Closure $key , string|Cake\Cache\CacheEngine
$config )
Constructor.
Parameters
- string|Closure $key
- The key or function to generate a key.
-
string|
Cake\Cache\CacheEngine
$config - The cache config name or cache engine instance.
Throws
RuntimeException
_resolveKey() protected ¶
_resolveKey( object $query )
Get/generate the cache key.
Parameters
- object $query
- The query to generate a key for.
Returns
string
Throws
RuntimeException