Cache
in package
This class provides the API interface to the cache storage drivers.
Tags
Table of Contents
- $logger : Horde_Log_Logger
- Logger.
- $params : array<string|int, mixed>
- Cache parameters.
- $storage : CacheStorage
- Storage object.
- __construct() : mixed
- Constructor.
- clear() : mixed
- Clears all data from the cache.
- exists() : bool
- Checks if a given key exists in the cache, valid for the given lifetime.
- expire() : bool
- Expire any existing data for the given key.
- get() : mixed
- Retrieve cached data.
- output() : bool
- Attempts to directly output a cached object.
- set() : mixed
- Store an object in the cache.
- testReadWrite() : bool
- Tests the driver for read/write access.
Properties
$logger
Logger.
protected
Horde_Log_Logger
$logger
$params
Cache parameters.
protected
array<string|int, mixed>
$params
= ['compress' => false, 'lifetime' => 86400]
$storage
Storage object.
protected
CacheStorage
$storage
Methods
__construct()
Constructor.
public
__construct(CacheStorage $storage[, array<string|int, mixed> $params = [] ]) : mixed
Parameters
- $storage : CacheStorage
-
The storage object.
- $params : array<string|int, mixed> = []
-
Parameter array:
- compress: (boolean) Compress data (if possible)? DEFAULT: false - lifetime: (integer) Lifetime of data, in seconds. DEFAULT: 86400 seconds - logger: (Horde_Log_Logger) Log object to use for log/debug messages.
Return values
mixed —clear()
Clears all data from the cache.
public
clear() : mixed
Tags
Return values
mixed —exists()
Checks if a given key exists in the cache, valid for the given lifetime.
public
exists(string $key, int $lifetime) : bool
Parameters
- $key : string
-
Cache key to check.
- $lifetime : int
-
Lifetime of the key in seconds.
Return values
bool —Existence.
expire()
Expire any existing data for the given key.
public
expire(string $key) : bool
Parameters
- $key : string
-
Cache key to expire.
Return values
bool —Success or failure.
get()
Retrieve cached data.
public
get(string $key[, int $lifetime = 1 ]) : mixed
Parameters
- $key : string
-
Object ID to query.
- $lifetime : int = 1
-
Lifetime of the object in seconds.
Tags
Return values
mixed —Cached data, or false if none was found.
output()
Attempts to directly output a cached object.
public
output(string $key[, int $lifetime = 1 ]) : bool
Parameters
- $key : string
-
Object ID to query.
- $lifetime : int = 1
-
Lifetime of the object in seconds.
Tags
Return values
bool —True if output or false if no object was found.
set()
Store an object in the cache.
public
set(string $key, string $data[, int $lifetime = null ]) : mixed
Parameters
- $key : string
-
Object ID used as the caching key.
- $data : string
-
Data to store in the cache.
- $lifetime : int = null
-
Object lifetime - i.e. the time before the data becomes available for garbage collection, in seconds. If null use the default Horde GC time. If 0 will not be GC'd.
Return values
mixed —testReadWrite()
Tests the driver for read/write access.
public
testReadWrite() : bool
Return values
bool —True if read/write is available.