PHP 클래스 CacheSource

저자: Johannes Donath
상속: extends Memcache
파일 보기 프로젝트 열기: jeremyharris/cacher 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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