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.
Located at Datasource/QueryCacher.php

Method Detail

__constructsource 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
\RuntimeException

_resolveCachersource protected

_resolveCacher( )

Get the cache engine.

Returns

Cake\Cache\CacheEngine
\Cake\Cache\CacheEngine

_resolveKeysource protected

_resolveKey( object $query )

Get/generate the cache key.

Parameters

object $query
The query to generate a key for.

Returns

string
string

Throws

RuntimeException
\RuntimeException

fetchsource 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.

storesource 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.1/class-Cake.Datasource.QueryCacher.html