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

 Methods

Constructor

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

Parameters

$options

array

Associative array of options

Exceptions

\Zend_Cache_Exception

Constructor

__construct(array|\Zend_Config $options = array()) : void
Inherited

Parameters

$options

array\Zend_Config

Associative array of options or Zend_Config instance

Exceptions

\Zend_Cache_Exception

callback for output buffering (shouldn't really be called manually)

_flush(string $data) : string

Parameters

$data

string

Buffered output

Returns

stringData to send to browser

Cancel the current caching process

cancel() 

Clean cache entries

clean(string $mode = 'all', array|string $tags = array()) : boolean
Inherited

Available modes are : 'all' (default) => remove all cache entries ($tags is not used) 'old' => remove too old cache entries ($tags is not used) 'matchingTag' => remove cache entries matching all given tags ($tags can be an array of strings or a single string) 'notMatchingTag' => remove cache entries not matching one of the given tags ($tags can be an array of strings or a single string) 'matchingAnyTag' => remove cache entries matching any given tags ($tags can be an array of strings or a single string)

Parameters

$mode

string

$tags

arraystring

Exceptions

\Zend_Cache_Exception

Returns

booleanTrue if ok

Returns the backend

getBackend() : \Zend_Cache_Backend
Inherited

Returns

\Zend_Cache_Backendbackend object

Return the filling percentage of the backend storage

getFillingPercentage() : integer
Inherited

Returns

integerinteger between 0 and 100

Return an array of stored cache ids

getIds() : array
Inherited

Returns

arrayarray of stored cache ids (string)

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

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

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

Parameters

$tags

array

array of tags

Returns

arrayarray of matching any cache ids (string)

Return an array of stored cache ids which match given tags

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

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

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
Inherited

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

Parameters

$tags

array

array of tags

Returns

arrayarray of not matching cache ids (string)

Return an array of metadatas for the given cache id

getMetadatas(string $id) : array
Inherited

The array will include these keys :

  • expire : the expire timestamp
  • tags : a string array of tags
  • mtime : timestamp of last modification time

Parameters

$id

string

cache id

Returns

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

Public frontend to get an option value

getOption(string $name) : mixed
Inherited

Parameters

$name

string

Name of the option

Exceptions

\Zend_Cache_Exception

Returns

mixedoption value

Return an array of stored tags

getTags() : array
Inherited

Returns

arrayarray of stored tags (string)

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

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

Parameters

$id

string

Cache id

$doNotTestCacheValidity

boolean

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

$doNotUnserialize

boolean

Do not serialize (even if automatic_serialization is true) => for internal use

Returns

mixedfalseCached datas

Remove a cache

remove(string $id) : boolean
Inherited

Parameters

$id

string

Cache id to remove

Returns

booleanTrue if ok

Save some data in a cache

save(mixed $data, string $id = null, array $tags = array(), integer $specificLifetime = false, integer $priority = 8) : boolean
Inherited

Parameters

$data

mixed

Data to put in cache (can be another type than string if automatic_serialization is on)

$id

string

Cache id (if not set, the last cache id will be used)

$tags

array

Cache tags

$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

Exceptions

\Zend_Cache_Exception

Returns

booleanTrue if no problem

Set the backend

setBackend(\Zend_Cache_Backend $backendObject) : void
Inherited

Parameters

$backendObject

\Zend_Cache_Backend

Exceptions

\Zend_Cache_Exception

Set options using an instance of type Zend_Config

setConfig(\Zend_Config $config) : \Zend_Cache_Core
Inherited

Parameters

$config

\Zend_Config

Returns

\Zend_Cache_Core

Force a new lifetime

setLifetime(integer $newLifetime) : void
Inherited

The new value is set for the core/frontend but for the backend too (directive)

Parameters

$newLifetime

integer

New lifetime (in seconds)

Public frontend to set an option

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

There is an additional validation (relatively to the protected _setOption method)

Parameters

$name

string

Name of the option

$value

mixed

Value of the option

Exceptions

\Zend_Cache_Exception

Start the cache

start(string $id = false, boolean $doNotDie = false) : boolean

Parameters

$id

string

(optional) A cache id (if you set a value here, maybe you have to use Output frontend instead)

$doNotDie

boolean

For unit testing only !

Returns

booleanTrue if the cache is hit (false else)

Test if a cache is available for the given id

test(string $id) : integer | false
Inherited

Parameters

$id

string

Cache id

Returns

integerfalseLast modified time of cache entry if it is available, false otherwise

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

touch(string $id, integer $extraLifetime) : boolean
Inherited

Parameters

$id

string

cache id

$extraLifetime

integer

Returns

booleantrue if ok

Make and return a cache id

_id(string $id) : string
Inherited

Checks 'cache_id_prefix' and returns new id with prefix or simply the id if null

Parameters

$id

string

Cache id

Returns

stringCache id (with or without prefix)

Log a message at the WARN (4) priority.

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

Parameters

$message

string

$priority

Exceptions

\Zend_Cache_Exception

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

Make an id depending on REQUEST_URI and superglobal arrays (depending on options)

_makeId() : mixed | false

Returns

mixedfalsea cache id (string), false if the cache should have not to be used

Make a partial id depending on options

_makePartialId(string $arrayName, boolean $bool1, boolean $bool2) : mixed | false

Parameters

$arrayName

string

Superglobal array name

$bool1

boolean

If true, cache is still on even if there are some variables in the superglobal array

$bool2

boolean

If true, we have to use the content of the superglobal array to make a partial id

Returns

mixedfalsePartial id (string) or false if the cache should have not to be used

Set the deprecated contentTypeMemorization option

_setContentTypeMemorization(boolean $value) : void
deprecated

Parameters

$value

boolean

value

Specific setter for the 'default_options' option (with some additional tests)

_setDefaultOptions(array $options) : void

Parameters

$options

array

Associative array

Exceptions

\Zend_Cache_Exception

Specific setter for the 'regexps' option (with some additional tests)

_setRegexps($regexps) : void

Parameters

$regexps

Exceptions

\Zend_Cache_Exception

Validate a cache id or a tag (security, reliable filenames, reserved prefixes.

_validateIdOrTag(string $string) : void
Inherited

..)

Throw an exception if a problem is found

Parameters

$string

string

Cache id or tag

Exceptions

\Zend_Cache_Exception

Validate a tags array (security, reliable filenames, reserved prefixes.

_validateTagsArray(array $tags) : void
Inherited

..)

Throw an exception if a problem is found

Parameters

$tags

array

Array of tags

Exceptions

\Zend_Cache_Exception

Set an option

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

Parameters

$name

string

Name of the option

$value

mixed

Value of the option

Exceptions

\Zend_Cache_Exception

 Properties

 

Internal array to store some options

$_activeOptions : array

Default

array()
 

Backend Object

$_backend : \Zend_Cache_Backend_Interface

Default

null
 

Array of capabilities of the backend (only if it implements Zend_Cache_Backend_ExtendedInterface)

$_backendCapabilities : array

Default

array()
 

If true, the page won't be cached

$_cancel : boolean

Default

false
 

Array of options which have to be transfered to backend

$_directivesList : array

Default

array('lifetime', 'logging', 'logger')
Static
 

True if the backend implements Zend_Cache_Backend_ExtendedInterface

$_extendedBackend : boolean

Default

false
 

Available options

$_options : array

Default

array('write_control' => true, 'caching' => true, 'cache_id_prefix' => null, 'automatic_serialization' => false, 'automatic_cleaning_factor' => 10, 'lifetime' => 3600, 'logging' => false, 'logger' => null, 'ignore_user_abort' => false)

====> (boolean) write_control :

  • Enable / disable write control (the cache is read just after writing to detect corrupt entries)
  • Enable write control will lightly slow the cache writing but not the cache reading Write control can detect some corrupt cache files but maybe it's not a perfect control

====> (boolean) caching :

  • Enable / disable caching (can be very useful for the debug of cached scripts)

=====> (string) cache_id_prefix :

  • prefix for cache ids (namespace)

====> (boolean) automatic_serialization :

  • Enable / disable automatic serialization
  • It can be used to save directly datas which aren't strings (but it's slower)

====> (int) automatic_cleaning_factor :

  • Disable / Tune the automatic cleaning process
  • The automatic cleaning process destroy too old (for the given life time) cache files when a new cache file is written : 0 => no automatic cache cleaning 1 => systematic cache cleaning x (integer) > 1 => automatic cleaning randomly 1 times on x cache write

====> (int) lifetime :

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

====> (boolean) logging :

  • If set to true, logging is activated (but the system is slower)

====> (boolean) ignore_user_abort

  • If set to true, the core will set the ignore_user_abort PHP flag inside the save() method to avoid cache corruptions in some cases (default false)
 

This frontend specific options

$_specificOptions : array

Default

array('http_conditional' => false, 'debug_header' => false, 'content_type_memorization' => false, 'memorize_headers' => array(), 'default_options' => array('cache_with_get_variables' => false, 'cache_with_post_variables' => false, 'cache_with_session_variables' => false, 'cache_with_files_variables' => false, 'cache_with_cookie_variables' => false, 'make_id_with_get_variables' => true, 'make_id_with_post_variables' => true, 'make_id_with_session_variables' => true, 'make_id_with_files_variables' => true, 'make_id_with_cookie_variables' => true, 'cache' => true, 'specific_lifetime' => false, 'tags' => array(), 'priority' => null), 'regexps' => array())

====> (boolean) http_conditional :

  • if true, http conditional mode is on WARNING : http_conditional OPTION IS NOT IMPLEMENTED FOR THE MOMENT (TODO)

====> (boolean) debug_header :

  • if true, a debug text is added before each cached pages

====> (boolean) content_type_memorization :

  • deprecated => use memorize_headers instead
  • if the Content-Type header is sent after the cache was started, the corresponding value can be memorized and replayed when the cache is hit (if false (default), the frontend doesn't take care of Content-Type header)

====> (array) memorize_headers :

  • an array of strings corresponding to some HTTP headers name. Listed headers will be stored with cache datas and "replayed" when the cache is hit

====> (array) default_options :

  • an associative array of default options :
    • (boolean) cache : cache is on by default if true
    • (boolean) cacheWithXXXVariables (XXXX = 'Get', 'Post', 'Session', 'Files' or 'Cookie') : if true, cache is still on even if there are some variables in this superglobal array if false, cache is off if there are some variables in this superglobal array
    • (boolean) makeIdWithXXXVariables (XXXX = 'Get', 'Post', 'Session', 'Files' or 'Cookie') : if true, we have to use the content of this superglobal array to make a cache id if false, the cache id won't be dependent of the content of this superglobal array
    • (int) specific_lifetime : cache specific lifetime (false => global lifetime is used, null => infinite lifetime, integer => this lifetime is used), this "lifetime" is probably only usefull when used with "regexps" array
    • (array) tags : array of tags (strings)
    • (int) priority : integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends

====> (array) regexps :

  • an associative array to set options only for some REQUEST_URI
  • keys are (pcre) regexps
  • values are associative array with specific options to set if the regexp matchs on $_SERVER['REQUEST_URI'] (see default_options for the list of available options)
  • if several regexps match the $_SERVER['REQUEST_URI'], only the last one will be used
inherited_from \Zend_Cache_Core::_specificOptions
 

Not used for the core, just a sort a hint to get a common setOption() method (for the core and for frontends)

$_specificOptions : array

Default

array()
 

Last used cache id

$_lastId : string

Default

null

 Constants

 

BACKEND_NOT_IMPLEMENTS_EXTENDED_IF

BACKEND_NOT_IMPLEMENTS_EXTENDED_IF = 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available' 
 

Messages

BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend'