PHP Class CacheSource

Author: Johannes Donath
Inheritance: extends Memcache
Afficher le fichier Open project: jeremyharris/cacher Class Usage Examples

Méthodes publiques

Свойство Type Description
$source DataSource Stored original datasource for fallback methods

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
_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

Method Details

__call() public méthode

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
Résultat mixed

__construct() public méthode

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() protected méthode

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
Résultat string

_map() protected méthode

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

_resetSource() protected méthode

Resets the model's datasource to the original
protected _resetSource ( Model $Model ) : boolean
$Model Model The model
Résultat boolean

clearModelCache() public méthode

* 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() public méthode

This ensures it is called on the original datasource properly.
public describe ( mixed $model ) : mixed
$model mixed
Résultat mixed

read() public méthode

Reads from cache if it exists. If not, it falls back to the original datasource to retrieve the data and cache it for later
See also: DataSource::read()
public read ( Model $Model, array $queryData = [], integer $recursive = null ) : array
$Model Model
$queryData array
$recursive integer
Résultat array Results

Property Details

$source public_oe property

Stored original datasource for fallback methods
public DataSource $source
Résultat DataSource