Path

ez components / documentation / api reference / 2009.2.1 / cache


eZ Components 2009.2.1

Cache: ezcCacheMemcacheBackend

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcCacheMemcacheBackend

This backend stores data in a Memcache. [source]

Parents

ezcCacheMemoryBackend
   |
   --ezcCacheMemcacheBackend

Constants

COMPRESS_THRESHOLD = 1000000 The compress threshold.
Nearly 1MB (48,576B less).
MAX_KEY_LENGTH = 249 Maximum length of a cache key for Memcached.

Member Variables

protected array(string=>int) $connectionCounter = array()
Keeps track of the number of backends using the same connection.

This is to avoid that the dtor of a backend accedentally closes a connection that is still in used by another backend.
protected string $connectionIdentifier
Stores the connection identifier.

This is generated in the ctor and used in the dtor.
protected array(string=>Memcache) $connections = array()
Stores the connections to Memcached.
protected resource $memcache
Holds an instance to a Memcache object.
protected ezcCacheStorageMemcacheOptions $options
Holds the options for this class.

Method Summary

public ezcCacheMemcacheBackend __construct( [$options = array()] )
Constructs a new ezcCacheMemcacheBackend object.
public void __destruct( )
Destructor for the Memcache backend.
public void acquireLock( $key, $waitTime, $maxTime )
Acquires a lock on the given $key.
public bool delete( $key, [$timeout = 0] )
Deletes the data from the cache associated with key $key. Returns true or false depending on the success of the operation.
public mixed fetch( $key )
Returns the data from the cache associated with key $key.
public void releaseLock( $key )
Releases a lock on the given $key.
public void reset( )
Resets the complete backend.
public bool store( $key, $var, [$expire = 0] )
Adds the $var data to the cache under the key $key. Returns true or false depending on the success of the operation.

Inherited Methods

From ezcCacheMemoryBackend :
public abstract bool ezcCacheMemoryBackend::delete()
Deletes the data associated with key $key.
public abstract mixed ezcCacheMemoryBackend::fetch()
Fetches the data associated with key $key.
public abstract bool ezcCacheMemoryBackend::store()
Stores the data $var under the key $key.

Methods

__construct

ezcCacheMemcacheBackend __construct( [ $options = array()] )
Constructs a new ezcCacheMemcacheBackend object.
For options for this backend see ezcCacheStorageMemcacheOptions.

Parameters

Name Type Description
$options array(string=>mixed)  

Throws

ClassDescription
ezcCacheMemcacheException If the connection to the Memcache host did not succeed.
ezcBaseExtensionNotFoundException If the PHP memcache and zlib extensions are not installed.

__destruct

void __destruct( )
Destructor for the Memcache backend.

acquireLock

void acquireLock( string $key, int $waitTime, int $maxTime )
Acquires a lock on the given $key.

Parameters

Name Type Description
$key string  
$waitTime int usleep()
$maxTime int seconds

delete

bool delete( string $key, [int $timeout = 0] )
Deletes the data from the cache associated with key $key. Returns true or false depending on the success of the operation.
The value $timeout specifies the timeout period in seconds for the delete command.

Parameters

Name Type Description
$key string  
$timeout int  

Redefinition of

Method Description
ezcCacheMemoryBackend::delete() Deletes the data associated with key $key.

fetch

mixed fetch( mixed $key )
Returns the data from the cache associated with key $key.

Parameters

Name Type Description
$key mixed  

Redefinition of

Method Description
ezcCacheMemoryBackend::fetch() Fetches the data associated with key $key.

releaseLock

void releaseLock( string $key )
Releases a lock on the given $key.

Parameters

Name Type Description
$key string  

reset

void reset( )
Resets the complete backend.
Marked private to not expose more of this interface to the user, since this will be removed in future versions.

store

bool store( string $key, mixed $var, [int $expire = 0] )
Adds the $var data to the cache under the key $key. Returns true or false depending on the success of the operation.

Parameters

Name Type Description
$key string  
$var mixed  
$expire int  

Redefinition of

Method Description
ezcCacheMemoryBackend::store() Stores the data $var under the key $key.

Last updated: Tue, 23 Mar 2010