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(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() ¶ 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
stringThrows
RuntimeExceptionfetch() ¶ 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|nullEither the cached results or 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
boolTrue if the data was successfully cached, false on failure