Provides consistant caching interface.

Cache objects can extend this interface and be used by the system or by users in their scripts. Objects should be Singletons

author David Lidstone
package dstruct_common

 Methods

Add to the cache, but only if it doesn't already exist.

add(string $key, mixed $var, integer $expire) : boolean

Parameters

$key

string

$var

mixed

$expire

integer

Time the data is valid for in seconds

Returns

booleanTRUE if value was actually added, FALSE if otherwise

Delete from the cache.

delete(string $key) : boolean

Parameters

$key

string

Returns

boolean

Fetch a cached value.

get(string $key) : mixed

Parameters

$key

string

Returns

mixed

Get an instance of the object.

getInstance() : object
Static

Objects are singletons and so use this method to get an instance. If you impliment this interface, it is recommended that you declare the __constructor() as protected

Returns

object

Cache is available.

hasServer() : boolean

Is the cache server this object uses available to be used by the system

Returns

boolean

Hits on the cache in this script execution.

hits() : integer

Not persistent. Counts the number of times this cache object has been queried and returned existing data. Please check the documentation for each classes implimentation of this method, as the functionallity may vary across classes.

Returns

integer

Misses on the cache in this script execution.

misses() 

Not persistent. Counts the number of times this cache object has been queried but had no data for that key. Please check the documentation for each classes implimentation of this method, as the functionallity may vary across classes.

Add to the cache, overwriting if the key already exists.

set(string $key, mixed $var, integer $expire) : boolean

Parameters

$key

string

$var

mixed

$expire

integer

Time the data is valid for in seconds

Returns

booleanTRUE if value was actually added, FALSE if otherwise

Writes to the cache in this script execution.

writes() 

Not persistent. Counts the number of times this cache object has been written to. Please check the documentation for each classes implimentation of this method, as the functionallity may vary across classes.