Class Zend_Cache_Core

Description
  • copyright: Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  • license: New BSD License

Located in /Cache/Core.php (line 28)


	
			
Direct descendents
Class Constant Summary
 BACKEND_NOT_IMPLEMENTS_EXTENDED_IF = 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available'
 BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend'
Variable Summary
Method Summary
 static void _validateIdOrTag (string $string)
 static void _validateTagsArray (array $tags)
 void __construct ([array|Zend_Config $options = array()])
 boolean clean ([string $mode = 'all'], [array|string $tags = array()])
 object backend getBackend ()
 array getIds ()
 array getIdsMatchingAnyTags ([array $tags = array()])
 array getIdsMatchingTags ([array $tags = array()])
 array getIdsNotMatchingTags ([array $tags = array()])
 array getMetadatas (string $id)
 mixed getOption (string $name)
 array getTags ()
 mixed|false load (string $id, [boolean $doNotTestCacheValidity = false], [boolean $doNotUnserialize = false])
 boolean remove (string $id)
 boolean save (mixed $data, [string $id = null], [array $tags = array()], [int $specificLifetime = false], [int $priority = 8])
 void setBackend (Zend_Cache_Backend $backendObject)
 void setLifetime (int $newLifetime)
 void setOption (string $name, mixed $value)
 int|false test (string $id)
 boolean touch (string $id, int $extraLifetime)
 string _id (string $id)
 void _log (string $message, [ $priority = 4])
 void _loggerSanity ()
Variables
static array $_directivesList = array('lifetime', 'logging', 'logger') (line 100)

Array of options which have to be transfered to backend

  • access: protected
object $_backend = null (line 41)

Backend Object

  • access: protected
array $_backendCapabilities = array() (line 128)

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

  • access: protected
boolean $_extendedBackend = false (line 121)

True if the backend implements Zend_Cache_Backend_ExtendedInterface

  • access: protected
array $_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
)
(line 83)

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

  • var: available options
  • access: protected
array $_specificOptions = array() (line 107)

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

  • access: protected

Redefined in descendants as:
Methods
static _validateIdOrTag (line 664)

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

Throw an exception if a problem is found

  • throws: Zend_Cache_Exception
  • access: protected
static void _validateIdOrTag (string $string)
  • string $string: Cache id or tag
static _validateTagsArray (line 686)

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

Throw an exception if a problem is found

  • throws: Zend_Cache_Exception
  • access: protected
static void _validateTagsArray (array $tags)
  • array $tags: Array of tags
Constructor __construct (line 137)

Constructor

  • throws: Zend_Cache_Exception
  • access: public
void __construct ([array|Zend_Config $options = array()])
  • array|Zend_Config $options: Associative array of options or Zend_Config instance

Redefined in descendants as:
clean (line 448)

Clean cache entries

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)

  • return: True if ok
  • throws: Zend_Cache_Exception
  • access: public
boolean clean ([string $mode = 'all'], [array|string $tags = array()])
  • string $mode
  • array|string $tags
getBackend (line 196)

Returns the backend

  • return: object
  • access: public
object backend getBackend ()
getFillingPercentage (line 611)

Return the filling percentage of the backend storage

  • return: integer between 0 and 100
  • access: public
int getFillingPercentage ()
getIds (line 568)

Return an array of stored cache ids

  • return: array of stored cache ids (string)
  • access: public
array getIds ()
getIdsMatchingAnyTags (line 538)

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

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

  • return: array of matching any cache ids (string)
  • access: public
array getIdsMatchingAnyTags ([array $tags = array()])
  • array $tags: array of tags
getIdsMatchingTags (line 472)

Return an array of stored cache ids which match given tags

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

  • return: array of matching cache ids (string)
  • access: public
array getIdsMatchingTags ([array $tags = array()])
  • array $tags: array of tags
getIdsNotMatchingTags (line 505)

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

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

  • return: array of not matching cache ids (string)
  • access: public
array getIdsNotMatchingTags ([array $tags = array()])
  • array $tags: array of tags
getMetadatas (line 630)

Return an array of metadatas for the given cache id

The array will include these keys :

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

  • return: array of metadatas (false if the cache id is not found)
  • access: public
array getMetadatas (string $id)
  • string $id: cache id
getOption (line 236)

Public frontend to get an option value

  • return: option value
  • throws: Zend_Cache_Exception
  • access: public
mixed getOption (string $name)
  • string $name: Name of the option
getTags (line 595)

Return an array of stored tags

  • return: array of stored tags (string)
  • access: public
array getTags ()
load (line 295)

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

  • return: Cached datas
  • access: public
mixed|false load (string $id, [boolean $doNotTestCacheValidity = false], [boolean $doNotUnserialize = false])
  • string $id: Cache id
  • boolean $doNotTestCacheValidity: If set to true, the cache validity won't be tested
  • boolean $doNotUnserialize: Do not serialize (even if automatic_serialization is true) => for internal use

Redefined in descendants as:
remove (line 420)

Remove a cache

  • return: True if ok
  • access: public
boolean remove (string $id)
  • string $id: Cache id to remove
save (line 343)

Save some data in a cache

  • return: True if no problem
  • throws: Zend_Cache_Exception
  • access: public
boolean save (mixed $data, [string $id = null], [array $tags = array()], [int $specificLifetime = false], [int $priority = 8])
  • mixed $data: Data to put in cache (can be another type than string if automatic_serialization is on)
  • string $id: Cache id (if not set, the last cache id will be used)
  • array $tags: Cache tags
  • int $specificLifetime: If != false, set a specific lifetime for this cache record (null => infinite lifetime)
  • int $priority: integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
setBackend (line 174)

Set the backend

  • throws: Zend_Cache_Exception
  • access: public
void setBackend (Zend_Cache_Backend $backendObject)
  • object $backendObject
setConfig (line 158)

Set options using an instance of type Zend_Config

  • access: public
Zend_Cache_Core setConfig ( $config)
setLifetime (line 279)

Force a new lifetime

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

  • access: public
void setLifetime (int $newLifetime)
  • int $newLifetime: New lifetime (in seconds)
setOption (line 211)

Public frontend to set an option

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

  • throws: Zend_Cache_Exception
  • access: public
void setOption (string $name, mixed $value)
  • string $name: Name of the option
  • mixed $value: Value of the option

Redefined in descendants as:
test (line 321)

Test if a cache is available for the given id

  • return: Last modified time of cache entry if it is available, false otherwise
  • access: public
int|false test (string $id)
  • string $id: Cache id

Redefined in descendants as:
touch (line 646)

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

  • return: true if ok
  • access: public
boolean touch (string $id, int $extraLifetime)
  • string $id: cache id
  • int $extraLifetime
_id (line 748)

Make and return a cache id

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

  • return: Cache id (with or without prefix)
  • access: protected
string _id (string $id)
  • string $id: Cache id
_log (line 728)

Log a message at the WARN (4) priority.

  • throws: Zend_Cache_Exception
  • access: protected
void _log (string $message, [ $priority = 4])
  • string $message
  • $priority
_loggerSanity (line 705)

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

Create a default log object if none is set.

  • throws: Zend_Cache_Exception
  • access: protected
void _loggerSanity ()
Class Constants
BACKEND_NOT_IMPLEMENTS_EXTENDED_IF = 'Current backend doesn\'t implement the Zend_Cache_Backend_ExtendedInterface, so this method is not available' (line 34)
BACKEND_NOT_SUPPORTS_TAG = 'tags are not supported by the current backend' (line 33)

Messages

Documentation generated on Mon, 21 Jun 2010 15:14:24 -0400 by phpDocumentor 1.4.3