PHP Class CacheBehavior

Inheritance: extends CActiveRecordBehavior
Mostrar archivo Open project: jeremyharris/cacher Class Usage Examples

Public Properties

Property Type Description
$cacheResults boolean Whether or not to cache this call's results
$settings array Settings

Public Methods

Method Description
beforeDelete ( Model $Model, $cascade = true ) Intercepts delete to use the caching datasource instead
beforeFind ( Model $Model, array $queryData ) Intercepts find to use the caching datasource instead
beforeSave ( Model $Model, $options = [] ) Intercepts save to use the caching datasource instead
clearCache ( Model $Model, $queryData = null ) : boolean Clears all of the cache for this model's find queries. Optionally, pass $queryData to just clear a specific query
setup ( Model $Model, array $config = [] ) Sets up a connection using passed settings

Protected Methods

Method Description
_prepareFind ( Model $Model, $query = [] ) * Prepares a query by adding missing data. This function is needed because reads on the database typically bypass Model::find() which is where the query is changed.

Method Details

_prepareFind() protected method

* Prepares a query by adding missing data. This function is needed because reads on the database typically bypass Model::find() which is where the query is changed.
See also: Model::find()
protected _prepareFind ( Model $Model, $query = [] )
$Model Model
$query The query

beforeDelete() public method

Intercepts delete to use the caching datasource instead
public beforeDelete ( Model $Model, $cascade = true )
$Model Model The calling model

beforeFind() public method

If $queryData['cacher'] is true, it will cache based on the setup settings If $queryData['cacher'] is a duration, it will cache using the setup settings and the new duration.
public beforeFind ( Model $Model, array $queryData )
$Model Model The calling model
$queryData array The query

beforeSave() public method

Intercepts save to use the caching datasource instead
public beforeSave ( Model $Model, $options = [] )
$Model Model The calling model

clearCache() public method

Clears all of the cache for this model's find queries. Optionally, pass $queryData to just clear a specific query
public clearCache ( Model $Model, $queryData = null ) : boolean
$Model Model The calling model
return boolean

setup() public method

### Config - config The name of an existing Cache configuration to use. Default is 'default' - clearOnSave Whether or not to delete the cache on saves - clearOnDelete Whether or not to delete the cache on deletes - auto Automatically cache or look for 'cache' in the find conditions where the key is true or a duration
See also: Cache::config()
public setup ( Model $Model, array $config = [] )
$Model Model The calling model
$config array Configuration settings

Property Details

$cacheResults public_oe property

Whether or not to cache this call's results
public bool $cacheResults
return boolean

$settings public_oe property

Settings
public array $settings
return array