\Cake\DatasourceQueryCacher

Handles caching queries and loading results from the cache.

Used by Cake\Datasource\QueryTrait internally.

Summary

Methods
Properties
Constants
__construct()
fetch()
store()
No public properties found
No constants found
_resolveKey()
_resolveCacher()
$_key
$_config
N/A
No private methods found
No private properties found
N/A

Properties

$_key

$_key : string|callable

The key or function to generate a key.

Type

string|callable

Methods

__construct()

__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

fetch()

fetch(object  $query) : \Cake\Datasource\ResultSetInterface|null

Load the cached results from the cache or run the query.

Parameters

object $query

The query the cache read is for.

Returns

\Cake\Datasource\ResultSetInterface|null —

Either the cached results or null.

store()

store(object  $query, \Traversable  $results) : boolean

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

_resolveKey()

_resolveKey(object  $query) : string

Get/generate the cache key.

Parameters

object $query

The query to generate a key for.

Throws

\RuntimeException

Returns

string

_resolveCacher()

_resolveCacher() : \Cake\Cache\CacheEngine

Get the cache engine.

Returns

\Cake\Cache\CacheEngine