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

PUBLIC METHOD FOR UNIT TESTING ONLY !

___expire(string $id) 

Force a cache record to expire

Parameters

$id

string

cache id

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 : Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags ($tags can be an array of strings or a single string) Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} ($tags can be an array of strings or a single string) Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags ($tags can be an array of strings or a single string)

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()

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
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

Note : return value is always "string" (unserialization is done by the core not by the backend)

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, integer $priority = 8) : 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)

$priority

integer

integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends

Returns

booleantrue if no problem

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

_getFastFillingPercentage()

_getFastFillingPercentage($mode) 

Parameters

$mode

Compute and return the lifetime for the fast backend

_getFastLifetime(integer $lifetime, integer $priority, integer $maxLifetime = null) : integer

Parameters

$lifetime

integer

original lifetime

$priority

integer

priority

$maxLifetime

integer

maximum lifetime

Returns

integerlifetime for the fast backend

Prepare a serialized array to store datas and metadatas informations

_prepareData(string $data, integer $lifetime, integer $priority) : string

Parameters

$data

string

data to store

$lifetime

integer

original lifetime

$priority

integer

priority

Returns

stringserialize array to store into cache

 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
 

Fast Backend

$_fastBackend : \Zend_Cache_Backend_ExtendedInterface

Default

 

Cache for the fast backend filling percentage

$_fastBackendFillingPercentage : integer

Default

null
 

Available options

$_options : array

Default

array('slow_backend' => 'File', 'fast_backend' => 'Apc', 'slow_backend_options' => array(), 'fast_backend_options' => array(), 'stats_update_factor' => 10, 'slow_backend_custom_naming' => false, 'fast_backend_custom_naming' => false, 'slow_backend_autoload' => false, 'fast_backend_autoload' => false, 'auto_fill_fast_cache' => true, 'auto_refresh_fast_cache' => true)

=====> (string) slow_backend :

  • Slow backend name
  • Must implement the Zend_Cache_Backend_ExtendedInterface
  • Should provide a big storage

=====> (string) fast_backend :

  • Flow backend name
  • Must implement the Zend_Cache_Backend_ExtendedInterface
  • Must be much faster than slow_backend

=====> (array) slow_backend_options :

  • Slow backend options (see corresponding backend)

=====> (array) fast_backend_options :

  • Fast backend options (see corresponding backend)

=====> (int) stats_update_factor :

  • Disable / Tune the computation of the fast backend filling percentage
  • When saving a record into cache : 1 => systematic computation of the fast backend filling percentage x (integer) > 1 => computation of the fast backend filling percentage randomly 1 times on x cache write

=====> (boolean) slow_backend_custom_naming : =====> (boolean) fast_backend_custom_naming : =====> (boolean) slow_backend_autoload : =====> (boolean) fast_backend_autoload :

  • See Zend_Cache::factory() method

=====> (boolean) auto_fill_fast_cache

  • If true, automatically fill the fast cache when a cache record was not found in fast cache, but did exist in slow cache. This can be usefull when a non-persistent cache like APC or Memcached got purged for whatever reason.

=====> (boolean) auto_refresh_fast_cache

  • If true, auto refresh the fast cache when a cache record is hit
inherited_from \Zend_Cache_Backend::_options
 

Available options

$_options : array

Default

array()
 

Slow Backend

$_slowBackend : \Zend_Cache_Backend_ExtendedInterface

Default