package Zend_Cache
subpackage Zend_Cache_Backend
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Cache_Backend

 Methods

Constructor

__construct(array $options = array()) : void
inherited_from \Zend_Cache_Backend::__construct()

Parameters

$options

array

associative array of options

Exceptions

\Zend_Cache_Exception

Constructor

__construct(array $options = array()
Inherited

Parameters

$options

array

Associative array of options

Clean some cache records

clean(string $mode = \Zend_Cache::CLEANING_MODE_ALL, array $tags = array()) : boolean

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

Parameters

$mode

string

Clean mode

$tags

array

Array of tags

Exceptions

\Zend_Cache_Exception

Returns

booleanTrue if no problem

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

getCapabilities() : array

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)
inherited_from \Zend_Cache_Backend_ExtendedInterface::getCapabilities()

Returns

arrayassociative of with capabilities

Return the filling percentage of the backend storage

getFillingPercentage() : integer
inherited_from \Zend_Cache_Backend_ExtendedInterface::getFillingPercentage()

Exceptions

\Zend_Cache_Exception

Returns

integerinteger between 0 and 100

Return an array of stored cache ids

getIds() : array
inherited_from \Zend_Cache_Backend_ExtendedInterface::getIds()

Returns

arrayarray of stored cache ids (string)

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

getIdsMatchingAnyTags(array $tags = array()) : array

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

inherited_from \Zend_Cache_Backend_ExtendedInterface::getIdsMatchingAnyTags()

Parameters

$tags

array

array of tags

Returns

arrayarray of any matching cache ids (string)

Return an array of stored cache ids which match given tags

getIdsMatchingTags(array $tags = array()) : array

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

inherited_from \Zend_Cache_Backend_ExtendedInterface::getIdsMatchingTags()

Parameters

$tags

array

array of tags

Returns

arrayarray of matching cache ids (string)

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

getIdsNotMatchingTags(array $tags = array()) : array

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

inherited_from \Zend_Cache_Backend_ExtendedInterface::getIdsNotMatchingTags()

Parameters

$tags

array

array of tags

Returns

arrayarray of not matching cache ids (string)

Get the life time

getLifetime(integer $specificLifetime) : integer
Inherited

if $specificLifetime is not false, the given specific life time is used else, the global lifetime is used

Parameters

$specificLifetime

integer

Returns

integerCache life time

Return an array of metadatas for the given cache id

getMetadatas(string $id) : array

The array must include these keys :

  • expire : the expire timestamp
  • tags : a string array of tags
  • mtime : timestamp of last modification time
inherited_from \Zend_Cache_Backend_ExtendedInterface::getMetadatas()

Parameters

$id

string

cache id

Returns

arrayarray of metadatas (false if the cache id is not found)

Returns an option

getOption(string $name) : mixed
Inherited

Parameters

$name

string

Optional, the options name to return

Exceptions

\Zend_Cache_Exceptions

Returns

mixed

Return an array of stored tags

getTags() : array
inherited_from \Zend_Cache_Backend_ExtendedInterface::getTags()

Returns

arrayarray of stored tags (string)

Determine system TMP directory and detect if we have read access

getTmpDir() : string
Inherited

inspired from Zend_File_Transfer_Adapter_Abstract

Exceptions

\Zend_Cache_Exception if unable to determine directory

Returns

string

Return true if the automatic cleaning is available for the backend

isAutomaticCleaningAvailable() : boolean

DEPRECATED : use getCapabilities() instead

inherited_from \Zend_Cache_Backend::isAutomaticCleaningAvailable()

Returns

boolean

Return true if the automatic cleaning is available for the backend

isAutomaticCleaningAvailable() : boolean
Inherited

DEPRECATED : use getCapabilities() instead

deprecated

Returns

boolean

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

load(string $id, boolean $doNotTestCacheValidity = false) : string | false

Parameters

$id

string

Cache id

$doNotTestCacheValidity

boolean

If set to true, the cache validity won't be tested

Returns

stringfalsecached datas

Remove a cache record

remove(string $id) : boolean

Parameters

$id

string

Cache id

Returns

booleanTrue if no problem

Save some string datas into a cache record

save(string $data, string $id, array $tags = array(), integer $specificLifetime = false) : boolean

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

Parameters

$data

string

Datas to cache

$id

string

Cache id

$tags

array

Array of strings, the cache record will be tagged by each string entry

$specificLifetime

integer

If != false, set a specific lifetime for this cache record (null => infinite lifetime)

Returns

booleanTrue if no problem

Set the frontend directives

setDirectives(array $directives) : void
inherited_from \Zend_Cache_Backend::setDirectives()

Parameters

$directives

array

Assoc of directives

Exceptions

\Zend_Cache_Exception

Set the frontend directives

setDirectives(array $directives) : void
Inherited

Parameters

$directives

array

Assoc of directives

Exceptions

\Zend_Cache_Exception

Set an option

setOption(string $name, mixed $value) : void
Inherited

Parameters

$name

string

$value

mixed

Exceptions

\Zend_Cache_Exception

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

test(string $id) : mixed | false

Parameters

$id

string

Cache id

Returns

mixedfalse(a cache is not available) or "last modified" timestamp (int) of the available cache record

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

touch(string $id, integer $extraLifetime) : boolean
inherited_from \Zend_Cache_Backend_ExtendedInterface::touch()

Parameters

$id

string

cache id

$extraLifetime

integer

Returns

booleantrue if ok

Verify if the given temporary directory is readable and writable

_isGoodTmpDir(string $dir) : boolean
Inherited

Parameters

$dir

string

temporary directory

Returns

booleantrue if the directory is ok

Log a message at the WARN (4) priority.

_log(string $message, integer $priority = 4) : void
Inherited

Parameters

$message

string

$priority

integer

Make sure if we enable logging that the Zend_Log class is available.

_loggerSanity() : void
Inherited

Create a default log object if none is set.

Exceptions

\Zend_Cache_Exception

 Properties

 

Frontend or Core directives

$_directives : array

Default

array('lifetime' => 3600, 'logging' => false, 'logger' => null)

=====> (int) lifetime :

  • Cache lifetime (in seconds)
  • If null, the cache is valid forever

=====> (int) logging :

  • if set to true, a logging is activated throw Zend_Log
 

Memcache object

$_memcache : mixed

Default

null
 

Available options

$_options : array

Default

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)

=====> (array) servers : an array of memcached server ; each memcached server is described by an associative array : 'host' => (string) : the name of the memcached server 'port' => (int) : the port of the memcached server 'persistent' => (bool) : use or not persistent connections to this memcached server 'weight' => (int) : number of buckets to create for this server which in turn control its probability of it being selected. The probability is relative to the total weight of all servers. 'timeout' => (int) : value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow. 'retry_interval' => (int) : controls how often a failed server will be retried, the default value is 15 seconds. Setting this parameter to -1 disables automatic retry. 'status' => (bool) : controls if the server should be flagged as online. 'failure_callback' => (callback) : Allows the user to specify a callback function to run upon encountering an error. The callback is run before failover is attempted. The function takes two parameters, the hostname and port of the failed server.

=====> (boolean) compression : true if you want to use on-the-fly compression

=====> (boolean) compatibility : true if you use old memcache server or extension

inherited_from \Zend_Cache_Backend::_options
 

Available options

$_options : array

Default

array()

 Constants

 

DEFAULT_FAILURE_CALLBACK

DEFAULT_FAILURE_CALLBACK = null 
 

Default Values

DEFAULT_HOST = '127.0.0.1' 
 

DEFAULT_PERSISTENT

DEFAULT_PERSISTENT = true 
 

DEFAULT_PORT

DEFAULT_PORT = 11211 
 

DEFAULT_RETRY_INTERVAL

DEFAULT_RETRY_INTERVAL = 15 
 

DEFAULT_STATUS

DEFAULT_STATUS = true 
 

DEFAULT_TIMEOUT

DEFAULT_TIMEOUT = 1 
 

DEFAULT_WEIGHT

DEFAULT_WEIGHT = 1 
 

Log message

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

TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND

TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND = 'Zend_Cache_Backend_Memcached::save() : tags are unsupported by the Memcached backend'