On this page
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
Method Summary
- 
    __construct() publicConstructor.
 - 
    _resolveCacher() protectedGet the cache engine.
 - 
    _resolveKey() protectedGet/generate the cache key.
 - 
    fetch() publicLoad the cached results from the cache or run the query.
 - 
    store() publicStore the result set into the cache.
 
Method Detail
__construct()source 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_resolveCacher()source protected
_resolveCacher( )
   Get the cache engine.
Returns
Cake\Cache\CacheEngine_resolveKey()source protected
_resolveKey( object $query )
   Get/generate the cache key.
Parameters
- 
     object 
$query - The query to generate a key for.
 
Returns
stringThrows
RuntimeExceptionfetch()source public
fetch( object $query )
   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|nullEither the cached results or null.
store()source public
store( object $query , Traversable $results )
   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
booleanTrue if the data was successfully cached, false on failure
© 2005–2017 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/3.3/class-Cake.Datasource.QueryCacher.html