Cache/Frontend/Page.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Cache  
Subpackage
Zend_Cache_Frontend  
Version
$Id: Page.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Cache_Frontend_Page

Package: Zend\Cache\Zend\Cache\Frontend
Parent(s)
\Zend_Cache_Core
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend'
inherited
Messages
Inherited from: \Zend_Cache_Core::BACKEND_NOT_SUPPORTS_TAG
>VConstant  BACKEND_NOT_IMPLEMENTS_EXTENDED_IF = 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'

Properties

>VPropertyprotectedarray $_activeOptions = array()
Internal array to store some options
Default valuearray()Details
Type
array
>VPropertyprotected\Zend_Cache_Backend_Interface $_backend = null
inherited
Backend Object
Inherited from: \Zend_Cache_Core::$$_backend
Default valuenullDetails
Type
\Zend_Cache_Backend_Interface
Inherited_from
\Zend_Cache_Core::$$_backend  
>VPropertyprotectedarray $_backendCapabilities = array()
inherited
Array of capabilities of the backend (only if it implements Zend_Cache_Backend_ExtendedInterface)
Inherited from: \Zend_Cache_Core::$$_backendCapabilities
Default valuearray()Details
Type
array
Inherited_from
\Zend_Cache_Core::$$_backendCapabilities  
>VPropertyprotectedboolean $_cancel = false
If true, the page won't be cached
Default valuefalseDetails
Type
boolean
>VPropertyprotectedarray $_directivesList = array('lifetime', 'logging', 'logger')
staticinherited
Array of options which have to be transfered to backend
Inherited from: \Zend_Cache_Core::$$_directivesList
Default valuearray('lifetime', 'logging', 'logger')Details
Type
array
Inherited_from
\Zend_Cache_Core::$$_directivesList  
>VPropertyprotectedboolean $_extendedBackend = false
inherited
True if the backend implements Zend_Cache_Backend_ExtendedInterface
Inherited from: \Zend_Cache_Core::$$_extendedBackend
Default valuefalseDetails
Type
boolean
Inherited_from
\Zend_Cache_Core::$$_extendedBackend  
>VPropertyprivatestring $_lastId = null
inherited
Last used cache id
Inherited from: \Zend_Cache_Core::$$_lastId
Default valuenullDetails
Type
string
Inherited_from
\Zend_Cache_Core::$$_lastId  
>VPropertyprotectedarray $_options = 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)
inherited
Available options
Inherited from: \Zend_Cache_Core::$$_options

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

Default valuearray('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)Details
Type
array
Inherited_from
\Zend_Cache_Core::$$_options  
>VPropertyprotectedarray $_specificOptions = 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())
This frontend specific options

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

Default valuearray('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())Details
Type
array

Methods

methodpublic__construct(array $options = array()) : void

Constructor

Parameters
NameTypeDescription
$optionsarray

Associative array of options

Throws
ExceptionDescription
\Zend_Cache_Exception
methodpublic_flush(string $data) : string

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

Parameters
NameTypeDescription
$datastring

Buffered output

Returns
TypeDescription
stringData to send to browser
methodprotected_id(string $id) : string
inherited

Make and return a cache id

Inherited from: \Zend_Cache_Core::_id()

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

Parameters
NameTypeDescription
$idstring

Cache id

Returns
TypeDescription
stringCache id (with or without prefix)
methodprotected_log(string $message,  $priority = 4) : void
inherited

Log a message at the WARN (4) priority.

Inherited from: \Zend_Cache_Core::_log()
Parameters
NameTypeDescription
$messagestring
$priority
Throws
ExceptionDescription
\Zend_Cache_Exception
methodprotected_loggerSanity() : void
inherited

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

Inherited from: \Zend_Cache_Core::_loggerSanity()

Create a default log object if none is set.

Throws
ExceptionDescription
\Zend_Cache_Exception
methodprotected_makeId() : mixed | false

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

Returns
TypeDescription
mixed | falsea cache id (string), false if the cache should have not to be used
methodprotected_makePartialId(string $arrayName, bool $bool1, bool $bool2) : mixed | false

Make a partial id depending on options

Parameters
NameTypeDescription
$arrayNamestring

Superglobal array name

$bool1bool

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

$bool2bool

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

Returns
TypeDescription
mixed | falsePartial id (string) or false if the cache should have not to be used
methodprotected_setContentTypeMemorization(boolean $value) : void

Set the deprecated contentTypeMemorization option

Parameters
NameTypeDescription
$valueboolean

value

Details
Deprecated
 
methodprotected_setDefaultOptions(array $options) : void

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

Parameters
NameTypeDescription
$optionsarray

Associative array

Throws
ExceptionDescription
\Zend_Cache_Exception
methodprivate_setOption(string $name, mixed $value) : void
inherited

Set an option

Inherited from: \Zend_Cache_Core::_setOption()
Parameters
NameTypeDescription
$namestring

Name of the option

$valuemixed

Value of the option

Throws
ExceptionDescription
\Zend_Cache_Exception
methodprotected_setRegexps( $regexps) : void

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

Parameters
NameTypeDescription
$regexps
Throws
ExceptionDescription
\Zend_Cache_Exception
methodprotected_validateIdOrTag(string $string) : void
staticinherited

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

Inherited from: \Zend_Cache_Core::_validateIdOrTag()

..)

Throw an exception if a problem is found

Parameters
NameTypeDescription
$stringstring

Cache id or tag

Throws
ExceptionDescription
\Zend_Cache_Exception
methodprotected_validateTagsArray(array $tags) : void
staticinherited

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

Inherited from: \Zend_Cache_Core::_validateTagsArray()

..)

Throw an exception if a problem is found

Parameters
NameTypeDescription
$tagsarray

Array of tags

Throws
ExceptionDescription
\Zend_Cache_Exception
methodpubliccancel() : void

Cancel the current caching process

methodpublicclean(string $mode = 'all', array | string $tags = array()) : boolean
inherited

Clean cache entries

Inherited from: \Zend_Cache_Core::clean()

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
NameTypeDescription
$modestring
$tagsarray | string
Returns
TypeDescription
booleanTrue if ok
Throws
ExceptionDescription
\Zend_Cache_Exception
methodpublicgetBackend() : \Zend_Cache_Backend
inherited

Returns the backend

Inherited from: \Zend_Cache_Core::getBackend()
Returns
TypeDescription
\Zend_Cache_Backendbackend object
methodpublicgetFillingPercentage() : int
inherited

Return the filling percentage of the backend storage

Inherited from: \Zend_Cache_Core::getFillingPercentage()
Returns
TypeDescription
intinteger between 0 and 100
methodpublicgetIds() : array
inherited

Return an array of stored cache ids

Inherited from: \Zend_Cache_Core::getIds()
Returns
TypeDescription
arrayarray of stored cache ids (string)
methodpublicgetIdsMatchingAnyTags(array $tags = array()) : array
inherited

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

Inherited from: \Zend_Cache_Core::getIdsMatchingAnyTags()

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

Parameters
NameTypeDescription
$tagsarray

array of tags

Returns
TypeDescription
arrayarray of matching any cache ids (string)
methodpublicgetIdsMatchingTags(array $tags = array()) : array
inherited

Return an array of stored cache ids which match given tags

Inherited from: \Zend_Cache_Core::getIdsMatchingTags()

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

Parameters
NameTypeDescription
$tagsarray

array of tags

Returns
TypeDescription
arrayarray of matching cache ids (string)
methodpublicgetIdsNotMatchingTags(array $tags = array()) : array
inherited

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

Inherited from: \Zend_Cache_Core::getIdsNotMatchingTags()

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

Parameters
NameTypeDescription
$tagsarray

array of tags

Returns
TypeDescription
arrayarray of not matching cache ids (string)
methodpublicgetMetadatas(string $id) : array
inherited

Return an array of metadatas for the given cache id

Inherited from: \Zend_Cache_Core::getMetadatas()

The array will include these keys : - expire : the expire timestamp - tags : a string array of tags - mtime : timestamp of last modification time

Parameters
NameTypeDescription
$idstring

cache id

Returns
TypeDescription
arrayarray of metadatas (false if the cache id is not found)
methodpublicgetOption(string $name) : mixed
inherited

Public frontend to get an option value

Inherited from: \Zend_Cache_Core::getOption()
Parameters
NameTypeDescription
$namestring

Name of the option

Returns
TypeDescription
mixedoption value
Throws
ExceptionDescription
\Zend_Cache_Exception
methodpublicgetTags() : array
inherited

Return an array of stored tags

Inherited from: \Zend_Cache_Core::getTags()
Returns
TypeDescription
arrayarray of stored tags (string)
methodpublicload(string $id, boolean $doNotTestCacheValidity = false, boolean $doNotUnserialize = false) : mixed | false
inherited

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

Inherited from: \Zend_Cache_Core::load()
Parameters
NameTypeDescription
$idstring

Cache id

$doNotTestCacheValidityboolean

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

$doNotUnserializeboolean

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

Returns
TypeDescription
mixed | falseCached datas
methodpublicremove(string $id) : boolean
inherited

Remove a cache

Inherited from: \Zend_Cache_Core::remove()
Parameters
NameTypeDescription
$idstring

Cache id to remove

Returns
TypeDescription
booleanTrue if ok
methodpublicsave(mixed $data, string $id = null, array $tags = array(), int $specificLifetime = false, int $priority = 8) : boolean
inherited

Save some data in a cache

Inherited from: \Zend_Cache_Core::save()
Parameters
NameTypeDescription
$datamixed

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

$idstring

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

$tagsarray

Cache tags

$specificLifetimeint

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

$priorityint

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

Returns
TypeDescription
booleanTrue if no problem
Throws
ExceptionDescription
\Zend_Cache_Exception
methodpublicsetBackend(\Zend_Cache_Backend $backendObject) : void
inherited

Set the backend

Inherited from: \Zend_Cache_Core::setBackend()
Parameters
NameTypeDescription
$backendObject\Zend_Cache_Backend
Throws
ExceptionDescription
\Zend_Cache_Exception
methodpublicsetConfig(\Zend_Config $config) : \Zend_Cache_Core
inherited

Set options using an instance of type Zend_Config

Inherited from: \Zend_Cache_Core::setConfig()
Parameters
NameTypeDescription
$config\Zend_Config
Returns
TypeDescription
\Zend_Cache_Core
methodpublicsetLifetime(int $newLifetime) : void
inherited

Force a new lifetime

Inherited from: \Zend_Cache_Core::setLifetime()

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

Parameters
NameTypeDescription
$newLifetimeint

New lifetime (in seconds)

methodpublicsetOption(string $name, mixed $value) : void
inherited

Public frontend to set an option

Inherited from: \Zend_Cache_Core::setOption()

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

Parameters
NameTypeDescription
$namestring

Name of the option

$valuemixed

Value of the option

Throws
ExceptionDescription
\Zend_Cache_Exception
methodpublicstart(string $id = false, boolean $doNotDie = false) : boolean

Start the cache

Parameters
NameTypeDescription
$idstring

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

$doNotDieboolean

For unit testing only !

Returns
TypeDescription
booleanTrue if the cache is hit (false else)
methodpublictest(string $id) : int | false
inherited

Test if a cache is available for the given id

Inherited from: \Zend_Cache_Core::test()
Parameters
NameTypeDescription
$idstring

Cache id

Returns
TypeDescription
int | falseLast modified time of cache entry if it is available, false otherwise
methodpublictouch(string $id, int $extraLifetime) : boolean
inherited

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

Inherited from: \Zend_Cache_Core::touch()
Parameters
NameTypeDescription
$idstring

cache id

$extraLifetimeint
Returns
TypeDescription
booleantrue if ok
Documentation was generated by phpDocumentor 2.0.0a12.