Class QueryCacher
Handles caching queries and loading results from the cache.
Used by Cake\Datasource\QueryTrait internally.
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(stringClosure $key, stringCake\Cache\CacheEngine $config)
Constructor.
Parameters
-
stringClosure
$key The key or function to generate a key.
-
stringCake\Cache\CacheEngine
$config The cache config name or cache engine instance.
Throws
RuntimeException
_resolveCacher() ¶ protected
_resolveCacher(): Cake\Cache\CacheEngine
Get the cache engine.
Returns
Cake\Cache\CacheEngine
_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): Cake\ORM\ResultSet|null
Load the cached results from the cache or run the query.
Parameters
-
object
$query The query the cache read is for.
Returns
Cake\ORM\ResultSet|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