Public Member Functions | Data Fields | Protected Attributes

Zend_Cache_Backend_Memcached Class Reference

Inheritance diagram for Zend_Cache_Backend_Memcached:
Zend_Cache_Backend Zend_Cache_Backend_ExtendedInterface Zend_Cache_Backend_Interface

Public Member Functions

 __construct (array $options=array())
 load ($id, $doNotTestCacheValidity=false)
 test ($id)
 save ($data, $id, $tags=array(), $specificLifetime=false)
 remove ($id)
 clean ($mode=Zend_Cache::CLEANING_MODE_ALL, $tags=array())
 isAutomaticCleaningAvailable ()
 setDirectives ($directives)
 getIds ()
 getTags ()
 getIdsMatchingTags ($tags=array())
 getIdsNotMatchingTags ($tags=array())
 getIdsMatchingAnyTags ($tags=array())
 getFillingPercentage ()
 getMetadatas ($id)
 touch ($id, $extraLifetime)
 getCapabilities ()

Data Fields

const DEFAULT_HOST = '127.0.0.1'
const DEFAULT_PORT = 11211
const DEFAULT_PERSISTENT = true
const DEFAULT_WEIGHT = 1
const DEFAULT_TIMEOUT = 1
const DEFAULT_RETRY_INTERVAL = 15
const DEFAULT_STATUS = true
const DEFAULT_FAILURE_CALLBACK = null
const TAGS_UNSUPPORTED_BY_CLEAN_OF_MEMCACHED_BACKEND = 'Zend_Cache_Backend_Memcached::clean() : tags are unsupported by the Memcached backend'
const TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND = 'Zend_Cache_Backend_Memcached::save() : tags are unsupported by the Memcached backend'

Protected Attributes

 $_options
 $_memcache = null

Detailed Description

Definition at line 41 of file Memcached.php.


Constructor & Destructor Documentation

__construct ( array $  options = array() )

Constructor

Parameters:
array$optionsassociative array of options
Exceptions:
Zend_Cache_Exception
Returns:
void

Reimplemented from Zend_Cache_Backend.

Definition at line 120 of file Memcached.php.


Member Function Documentation

clean ( mode = Zend_Cache::CLEANING_MODE_ALL,
tags = array() 
)

Clean some cache records

Available modes are : 'all' (default) => remove all cache entries ($tags is not used) 'old' => unsupported 'matchingTag' => unsupported 'notMatchingTag' => unsupported 'matchingAnyTag' => unsupported

Parameters:
string$modeClean mode
array$tagsArray of tags
Exceptions:
Zend_Cache_Exception
Returns:
boolean True if no problem

Implements Zend_Cache_Backend_Interface.

Definition at line 258 of file Memcached.php.

getCapabilities (  )

Return an associative array of capabilities (booleans) of the backend

The array must include these keys :

  • automatic_cleaning (is automating cleaning necessary)
  • tags (are tags supported)
  • expired_read (is it possible to read expired cache records (for doNotTestCacheValidity option for example))
  • priority does the backend deal with priority when saving
  • infinite_lifetime (is infinite lifetime can work with this backend)
  • get_list (is it possible to get the list of cache ids and the complete list of tags)
Returns:
array associative of with capabilities

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 490 of file Memcached.php.

getFillingPercentage (  )

Return the filling percentage of the backend storage

Exceptions:
Zend_Cache_Exception
Returns:
int integer between 0 and 100

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 379 of file Memcached.php.

getIds (  )

Return an array of stored cache ids

Returns:
array array of stored cache ids (string)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 314 of file Memcached.php.

getIdsMatchingAnyTags ( tags = array() )

Return an array of stored cache ids which match any given tags

In case of multiple tags, a logical AND is made between tags

Parameters:
array$tagsarray of tags
Returns:
array array of any matching cache ids (string)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 367 of file Memcached.php.

getIdsMatchingTags ( tags = array() )

Return an array of stored cache ids which match given tags

In case of multiple tags, a logical AND is made between tags

Parameters:
array$tagsarray of tags
Returns:
array array of matching cache ids (string)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 339 of file Memcached.php.

getIdsNotMatchingTags ( tags = array() )

Return an array of stored cache ids which don't match given tags

In case of multiple tags, a logical OR is made between tags

Parameters:
array$tagsarray of tags
Returns:
array array of not matching cache ids (string)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 353 of file Memcached.php.

getMetadatas ( id )

Return an array of metadatas for the given cache id

The array must include these keys :

  • expire : the expire timestamp
  • tags : a string array of tags
  • mtime : timestamp of last modification time
Parameters:
string$idcache id
Returns:
array array of metadatas (false if the cache id is not found)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 418 of file Memcached.php.

getTags (  )

Return an array of stored tags

Returns:
array array of stored tags (string)

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 325 of file Memcached.php.

isAutomaticCleaningAvailable (  )

Return true if the automatic cleaning is available for the backend

Returns:
boolean

Reimplemented from Zend_Cache_Backend.

Definition at line 283 of file Memcached.php.

load ( id,
doNotTestCacheValidity = false 
)

Test if a cache is available for the given id and (if yes) return it (false else)

Parameters:
string$idCache id
boolean$doNotTestCacheValidityIf set to true, the cache validity won't be tested
Returns:
string|false cached datas

Implements Zend_Cache_Backend_Interface.

Definition at line 178 of file Memcached.php.

remove ( id )

Remove a cache record

Parameters:
string$idCache id
Returns:
boolean True if no problem

Implements Zend_Cache_Backend_Interface.

Definition at line 238 of file Memcached.php.

save ( data,
id,
tags = array(),
specificLifetime = false 
)

Save some string datas into a cache record

Note : $data is always "string" (serialization is done by the core not by the backend)

Parameters:
string$dataDatas to cache
string$idCache id
array$tagsArray of strings, the cache record will be tagged by each string entry
int$specificLifetimeIf != false, set a specific lifetime for this cache record (null => infinite lifetime)
Returns:
boolean True if no problem

Implements Zend_Cache_Backend_Interface.

Definition at line 214 of file Memcached.php.

setDirectives ( directives )

Set the frontend directives

Parameters:
array$directivesAssoc of directives
Exceptions:
Zend_Cache_Exception
Returns:
void

Reimplemented from Zend_Cache_Backend.

Definition at line 295 of file Memcached.php.

test ( id )

Test if a cache is available or not (for the given id)

Parameters:
string$idCache id
Returns:
mixed|false (a cache is not available) or "last modified" timestamp (int) of the available cache record

Implements Zend_Cache_Backend_Interface.

Definition at line 193 of file Memcached.php.

touch ( id,
extraLifetime 
)

Give (if possible) an extra lifetime to the given cache id

Parameters:
string$idcache id
int$extraLifetime
Returns:
boolean true if ok

Implements Zend_Cache_Backend_ExtendedInterface.

Definition at line 446 of file Memcached.php.


Field Documentation

$_options [protected]
Initial value:
 array(
        'servers' => array(array(
            'host' => self::DEFAULT_HOST,
            'port' => self::DEFAULT_PORT,
            'persistent' => self::DEFAULT_PERSISTENT,
            'weight'  => self::DEFAULT_WEIGHT,
            'timeout' => self::DEFAULT_TIMEOUT,
            'retry_interval' => self::DEFAULT_RETRY_INTERVAL,
            'status' => self::DEFAULT_STATUS,
            'failure_callback' => self::DEFAULT_FAILURE_CALLBACK
        )),
        'compression' => false,
        'compatibility' => false,
    )

Reimplemented from Zend_Cache_Backend.

Definition at line 91 of file Memcached.php.

const DEFAULT_HOST = '127.0.0.1'

Default Values

Definition at line 46 of file Memcached.php.

const TAGS_UNSUPPORTED_BY_CLEAN_OF_MEMCACHED_BACKEND = 'Zend_Cache_Backend_Memcached::clean() : tags are unsupported by the Memcached backend'

Log message

Definition at line 58 of file Memcached.php.


The documentation for this class was generated from the following file: