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

Method Summary

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

string

Throws

RuntimeException

fetch()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|null
Either 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

boolean
True if the data was successfully cached, false on failure

© 2005–2016 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.
http://api.cakephp.org/3.2/class-Cake.Datasource.QueryCacher.html