Elgg  Version 2.3
Public Member Functions | List of all members
Elgg\Cache\Pool Interface Reference
Inheritance diagram for Elgg\Cache\Pool:
Elgg\Cache\Pool\InMemory Elgg\Cache\Pool\Noop Elgg\Cache\Pool\StashWrapper

Public Member Functions

 get ($key, callable $callback=null, $default=null)
 Fetches a value from the cache, with the option of calculating on miss. More...
 
 invalidate ($key)
 Forcefully invalidates the value associated with the given key. More...
 
 put ($key, $value)
 Prime the cache to a specific value. More...
 

Detailed Description

Definition at line 19 of file Pool.php.

Member Function Documentation

Elgg\Cache\Pool::get (   $key,
callable  $callback = null,
  $default = null 
)

Fetches a value from the cache, with the option of calculating on miss.

Parameters
string | int$keyA plain string ID for the cache entry
callable | null$callbackLogic for calculating the cache entry on miss
mixed$defaultDefault value returned if the value is missing and no callback is provided
Returns
mixed The cache value or the $default if no value and no callable

Implemented in Elgg\Cache\Pool\StashWrapper, Elgg\Cache\Pool\InMemory, and Elgg\Cache\Pool\Noop.

Elgg\Cache\Pool::invalidate (   $key)

Forcefully invalidates the value associated with the given key.

Implementations must:

  • Immediately consider the value stale
  • Recalculate the value at the next opportunity
Parameters
string | int$keyA plain string ID for the cache entry to invalidate.
Returns
void

Implemented in Elgg\Cache\Pool\StashWrapper, Elgg\Cache\Pool\InMemory, and Elgg\Cache\Pool\Noop.

Elgg\Cache\Pool::put (   $key,
  $value 
)

Prime the cache to a specific value.

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.

Parameters
string | int$keyA plain string ID for the cache entry
mixed$valueThe cache value
Returns
void

Implemented in Elgg\Cache\Pool\StashWrapper, Elgg\Cache\Pool\InMemory, and Elgg\Cache\Pool\Noop.


The documentation for this interface was generated from the following file: