PHP Interface Elgg\Cache\Pool

Exactly how/when the values are invalidated is not specified by this API, except that specific values can be forcefully invalidated with ::invalidate(). WARNING: API IN FLUX. DO NOT USE DIRECTLY.
Since: 1.10.0
ファイルを表示 Open project: elgg/elgg Interface Usage Examples

Public Methods

Method Description
get ( string | integer $key, callable $callback = null, mixed $default = null ) : mixed Fetches a value from the cache, with the option of calculating on miss
invalidate ( string | integer $key ) : void Forcefully invalidates the value associated with the given key.
put ( string | integer $key, mixed $value ) : void Prime the cache to a specific value.

Method Details

get() public method

Fetches a value from the cache, with the option of calculating on miss
public get ( string | integer $key, callable $callback = null, mixed $default = null ) : mixed
$key string | integer A plain string ID for the cache entry
$callback callable Logic for calculating the cache entry on miss
$default mixed Default value returned if the value is missing and no callback is provided
return mixed The cache value or the $default if no value and no callable

invalidate() public method

Implementations must: * Immediately consider the value stale * Recalculate the value at the next opportunity
public invalidate ( string | integer $key ) : void
$key string | integer A plain string ID for the cache entry to invalidate.
return void

put() public method

This is useful when the value was calculated by some out-of-band means. For example, when a list of rows is fetched from the database, you can prime the cache for each individual result.
public put ( string | integer $key, mixed $value ) : void
$key string | integer A plain string ID for the cache entry
$value mixed The cache value
return void