PHP Класс CacheSource

Автор: Johannes Donath
Наследование: extends Memcache
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$source DataSource Stored original datasource for fallback methods

Открытые методы

Метод Описание
__call ( string $name, array $arguments ) : mixed Redirects calls to original datasource methods. Needed if the Cacher.Cache behavior is attached before other behaviors that use the model's datasource methods.
__construct ( array $config = [] ) Constructor
clearModelCache ( Model $Model, $query = null ) * Clears the cache for a specific model and rewrites the map. Pass query to clear a specific query's cached results
describe ( mixed $model ) : mixed Since Datasource has the method describe(), it won't be caught __call().
read ( Model $Model, array $queryData = [], integer $recursive = null ) : array Reads from cache if it exists. If not, it falls back to the original datasource to retrieve the data and cache it for later

Защищенные методы

Метод Описание
_key ( Model $Model, array $query ) : string Hashes a query into a unique string and creates a cache key
_map ( Model $Model, string $key ) Creates a cache map (used for deleting cache keys or groups)
_resetSource ( Model $Model ) : boolean Resets the model's datasource to the original

Описание методов

__call() публичный Метод

Redirects calls to original datasource methods. Needed if the Cacher.Cache behavior is attached before other behaviors that use the model's datasource methods.
public __call ( string $name, array $arguments ) : mixed
$name string Original db source function name
$arguments array Arguments
Результат mixed

__construct() публичный Метод

Sets default options if none are passed when the datasource is created and creates the cache configuration. If a config is passed and is a valid Cache configuration, CacheSource uses its settings ### Extra config settings - original The name of the original datasource, i.e., 'default' (required) - config The name of the Cache configuration to use. Uses 'default' by default - other settings required by DataSource...
public __construct ( array $config = [] )
$config array Configure options

_key() защищенный Метод

Hashes a query into a unique string and creates a cache key
protected _key ( Model $Model, array $query ) : string
$Model Model The model
$query array The query
Результат string

_map() защищенный Метод

Creates a cache map (used for deleting cache keys or groups)
protected _map ( Model $Model, string $key )
$Model Model
$key string

_resetSource() защищенный Метод

Resets the model's datasource to the original
protected _resetSource ( Model $Model ) : boolean
$Model Model The model
Результат boolean

clearModelCache() публичный Метод

* Clears the cache for a specific model and rewrites the map. Pass query to clear a specific query's cached results
public clearModelCache ( Model $Model, $query = null )
$Model Model The model to clear the cache for
$query If null, clears all for this model

describe() публичный Метод

This ensures it is called on the original datasource properly.
public describe ( mixed $model ) : mixed
$model mixed
Результат mixed

read() публичный Метод

Reads from cache if it exists. If not, it falls back to the original datasource to retrieve the data and cache it for later
См. также: DataSource::read()
public read ( Model $Model, array $queryData = [], integer $recursive = null ) : array
$Model Model
$queryData array
$recursive integer
Результат array Results

Описание свойств

$source публичное свойство

Stored original datasource for fallback methods
public DataSource $source
Результат DataSource