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

Destructor

__destruct() : void

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

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

Exceptions

\Zend_Cache_Exception

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

Deal with the automatic vacuum process

_automaticVacuum() : void

Build the database structure

_buildStructure() : false

Returns

false

Check if the database structure is ok (with the good version), if no : build it

_checkAndBuildStructure() : boolean

Exceptions

\Zend_Cache_Exception

Returns

booleanTrue if ok

Check if the database structure is ok (with the good version)

_checkStructureVersion() : boolean

Returns

booleanTrue if ok

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

Returns

booleanTrue if no problem

Return the connection resource

_getConnection() : resource

If we are not connected, the connection is made

Exceptions

\Zend_Cache_Exception

Returns

resourceConnection resource

Execute an SQL query silently

_query(string $query) : mixed | false

Parameters

$query

string

SQL query

Returns

mixedfalsequery results

Register a cache id with the given tag

_registerTag(string $id, string $tag) : boolean

Parameters

$id

string

Cache id

$tag

string

Tag

Returns

booleanTrue if no problem

 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
 

Available options

$_options : array

Default

array('cache_db_complete_path' => null, 'automatic_vacuum_factor' => 10)

=====> (string) cache_db_complete_path :

  • the complete path (filename included) of the SQLITE database

====> (int) automatic_vacuum_factor :

  • Disable / Tune the automatic vacuum process
  • The automatic vacuum process defragment the database file (and make it smaller) when a clean() or delete() is called 0 => no automatic vacuum 1 => systematic vacuum (when delete() or clean() methods are called) x (integer) > 1 => automatic vacuum randomly 1 times on x clean() or delete()
inherited_from \Zend_Cache_Backend::_options
 

Available options

$_options : array

Default

array()
 

DB ressource

$_db : mixed

Default

null
 

Boolean to store if the structure has benn checked or not

$_structureChecked : boolean

Default

false