PHP Class lithium\storage\cache\adapter\Apc

The APC cache adapter is meant to be used through the Cache interface, which abstracts away key generation, adapter instantiation and filter implementation. A simple configuration of this adapter can be accomplished in config/bootstrap/cache.php as follows: {{{ Cache::config(array( 'cache-config-name' => array('adapter' => 'Apc') )); }}} This APC adapter provides basic support for write, read, delete and clear cache functionality, as well as allowing the first four methods to be filtered as per the Lithium filtering system. Additionally, This adapter defines several methods that are _not_ implemented in other adapters, and are thus non-portable - see the documentation for Cache as to how these methods should be accessed. This adapter supports multi-key write, read and delete operations. Learn more about APC in the PHP APC manual.
See also: lithium\storage\Cache::key()
Inheritance: extends lithium\core\Object
Show file Open project: unionofrad/lithium Class Usage Examples

Public Methods

Method Description
__construct ( array $config = [] ) : void Constructor.
clear ( ) : boolean Clears entire user-space cache by flushing it. All cache keys using the configuration but *without* honoring the scope are removed.
decrement ( string $key, integer $offset = 1 ) : integer | boolean Performs an atomic decrement operation on specified numeric cache item.
delete ( array $keys ) : boolean Will attempt to remove specified keys from the user space cache.
enabled ( ) : boolean Determines if the APC extension has been installed and if the userspace cache is available.
increment ( string $key, integer $offset = 1 ) : integer | boolean Performs an atomic increment operation on specified numeric cache item.
read ( array $keys ) : array Read values from the cache. Will attempt to return an array of data containing key/value pairs of the requested data.
write ( array $keys, string | integer $expiry = null ) : boolean Write values to the cache. All items to be cached will receive an expiration time of $expiry.

Method Details

__construct() public method

Constructor.
See also: lithium\storage\Cache::config()
public __construct ( array $config = [] ) : void
$config array Configuration for this cache adapter. These settings are queryable through `Cache::config('name')`. The available options are as follows: - `'scope'` _string_: Scope which will prefix keys; per default not set. - `'expiry'` _mixed_: The default expiration time for cache values, if no value is otherwise set. Can be either a `strtotime()` compatible tring or TTL in seconds. To indicate items should not expire use `Cache::PERSIST`. Defaults to `+1 hour`.
return void

clear() public method

The behavior and result when removing a single key during this process fails is unknown.
public clear ( ) : boolean
return boolean `true` on successful clearing, `false` otherwise.

decrement() public method

Note that, as per the APC specification: If the item's value is not numeric, the decrement operation has no effect on the key - it retains its original non-integer value.
public decrement ( string $key, integer $offset = 1 ) : integer | boolean
$key string Key of numeric cache item to decrement.
$offset integer Offset to decrement - defaults to `1`.
return integer | boolean The item's new value on successful decrement, else `false`.

delete() public method

Will attempt to remove specified keys from the user space cache.
public delete ( array $keys ) : boolean
$keys array Keys to uniquely identify the cached items.
return boolean `true` on successful delete, `false` otherwise.

enabled() public static method

Determines if the APC extension has been installed and if the userspace cache is available.
public static enabled ( ) : boolean
return boolean `true` if enabled, `false` otherwise.

increment() public method

Note that, as per the APC specification: If the item's value is not numeric, the increment operation has no effect on the key - it retains its original non-integer value.
public increment ( string $key, integer $offset = 1 ) : integer | boolean
$key string Key of numeric cache item to increment.
$offset integer Offset to increment - defaults to `1`.
return integer | boolean The item's new value on successful increment, else `false`.

read() public method

Read values from the cache. Will attempt to return an array of data containing key/value pairs of the requested data.
public read ( array $keys ) : array
$keys array Keys to uniquely identify the cached items.
return array Cached values keyed by cache keys on successful read, keys which could not be read will not be included in the results array.

write() public method

Write values to the cache. All items to be cached will receive an expiration time of $expiry.
public write ( array $keys, string | integer $expiry = null ) : boolean
$keys array Key/value pairs with keys to uniquely identify the to-be-cached item.
$expiry string | integer A `strtotime()` compatible cache time or TTL in seconds. To persist an item use `\lithium\storage\Cache::PERSIST`.
return boolean `true` on successful write, `false` otherwise.