\Horde_Cache

This class provides the API interface to the cache storage drivers.

Summary

Methods
Properties
Constants
__construct()
output()
get()
set()
exists()
expire()
clear()
testReadWrite()
No public properties found
No constants found
No protected methods found
$_params
$_logger
$_storage
N/A
No private methods found
No private properties found
N/A

Properties

$_params

$_params : array

Cache parameters.

Type

array

$_logger

$_logger : \Horde_Log_Logger

Logger.

Type

\Horde_Log_Logger

$_storage

$_storage : \Horde_Cache_Storage

Storage object.

Type

\Horde_Cache_Storage

Methods

__construct()

__construct(\Horde_Cache_Storage  $storage, array  $params = array()) 

Constructor.

Parameters

\Horde_Cache_Storage $storage

The storage object.

array $params

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.

output()

output(string  $key, integer  $lifetime = 1) : boolean

Attempts to directly output a cached object.

Parameters

string $key

Object ID to query.

integer $lifetime

Lifetime of the object in seconds.

Returns

boolean —

True if output or false if no object was found.

get()

get(string  $key, integer  $lifetime = 1) : mixed

Retrieve cached data.

Parameters

string $key

Object ID to query.

integer $lifetime

Lifetime of the object in seconds.

Returns

mixed —

Cached data, or false if none was found.

set()

set(string  $key, string  $data, integer  $lifetime = null) 

Store an object in the cache.

Parameters

string $key

Object ID used as the caching key.

string $data

Data to store in the cache.

integer $lifetime

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.

exists()

exists(string  $key, integer  $lifetime = 1) : boolean

Checks if a given key exists in the cache, valid for the given lifetime.

Parameters

string $key

Cache key to check.

integer $lifetime

Lifetime of the key in seconds.

Returns

boolean —

Existence.

expire()

expire(string  $key) : boolean

Expire any existing data for the given key.

Parameters

string $key

Cache key to expire.

Returns

boolean —

Success or failure.

clear()

clear() 

Clears all data from the cache.

Throws

\Horde_Cache_Exception

testReadWrite()

testReadWrite() : boolean

Tests the driver for read/write access.

Returns

boolean —

True if read/write is available.