Wraps PHP's MemCache class.

Wrapping MemCache gives a consistent object as defined by DStructCacheInterface.

package dstruct_common

 Methods

Add entry to cache.

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

Will add an entry if $key does not already exist.

see \Memcache::add()

Parameters

$key

string

Key in the cache

$var

string

to cache

$flags

array

Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib).

$expire

integer

Time in seconds. Default = 604800 = one week

Returns

booleanTrue for success

Delete from cache.

delete(string $key) : boolean
see \Memcache::delete()

Parameters

$key

string

Key in the cache

Returns

boolean

Get data from cache.

get(string $key, integer $flags) : string
see \Memcache::get()

Parameters

$key

string

Key in the cache

$flags

integer

See {@link http://php.net/manual/en/memcache.get.php}

Returns

string

Get and instance of this Singleton 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

todo rewrite to handle pools

Returns

object

Server is available?

hasServer() : boolean

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

see \DStructCacheInterface::hasServer()

Returns

boolean

Cache hits.

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.

see \DStructCacheInterface::hits()

Returns

integer

Cache misses.

misses() : integer

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.

see \DStructCacheInterface::misses()

Returns

integer

Sets a new entry or overwrites an existing one.

set(string $key, string $var, integer $flags, integer $expire) : boolean
see \Memcache::set()

Parameters

$key

string

Key in the cache

$var

string

$flags

integer

See {@link http://php.net/manual/en/memcache.get.php}

$expire

integer

Time in seconds. Default = 604800 = one week

Returns

booleanTRUE if value was actually added, FALSE if otherwise

Cache writes.

writes() : integer

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.

see \DStructCacheInterface::writes()

Returns

integer

Class constructor.

__construct() 
todo Check connecting to servers works as expected (what is returned when adding server).

 Properties

 

$failedwrites : integer
 

$hasserver : boolean
 

$hits : integer
 

$instance : object
 

$misses : integer
 

$writes : integer