Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

Zend_Cache_Core Class Reference

Inheritance diagram for Zend_Cache_Core:
Zend_Cache_Frontend_Class Zend_Cache_Frontend_File Zend_Cache_Frontend_Function Zend_Cache_Frontend_Output Zend_Cache_Frontend_Page

Public Member Functions

 __construct ($options=array())
 setConfig (Zend_Config $config)
 setBackend (Zend_Cache_Backend $backendObject)
 getBackend ()
 setOption ($name, $value)
 getOption ($name)
 setLifetime ($newLifetime)
 load ($id, $doNotTestCacheValidity=false, $doNotUnserialize=false)
 test ($id)
 save ($data, $id=null, $tags=array(), $specificLifetime=false, $priority=8)
 remove ($id)
 clean ($mode= 'all', $tags=array())
 getIdsMatchingTags ($tags=array())
 getIdsNotMatchingTags ($tags=array())
 getIds ()
 getTags ()
 getFillingPercentage ()
 getMetadatas ($id)
 touch ($id, $extraLifetime)

Protected Member Functions

 _loggerSanity ()
 _log ($message, $priority=4)
 _id ($id)

Static Protected Member Functions

static _validateIdOrTag ($string)
static _validateTagsArray ($tags)

Protected Attributes

 $_backend = null
 $_options
 $_specificOptions = array()
 $_extendedBackend = false
 $_backendCapabilities = array()

Static Protected Attributes

static $_directivesList = array('lifetime', 'logging', 'logger')

Detailed Description

Definition at line 28 of file Core.php.


Constructor & Destructor Documentation

__construct ( options = array() )

Constructor

Parameters:
array | Zend_Config$optionsAssociative array of options or Zend_Config instance
Exceptions:
Zend_Cache_Exception
Returns:
void

Definition at line 131 of file Core.php.


Member Function Documentation

_id ( id ) [protected]

Make and return a cache id

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

Parameters:
string$idCache id
Returns:
string Cache id (with or without prefix)

Definition at line 675 of file Core.php.

_log ( message,
priority = 4 
) [protected]

Log a message at the WARN (4) priority.

Parameters:
string$message
Exceptions:
Zend_Cache_Exception
Returns:
void

Definition at line 655 of file Core.php.

_loggerSanity (  ) [protected]

Make sure if we enable logging that the Zend_Log class is available. Create a default log object if none is set.

Exceptions:
Zend_Cache_Exception
Returns:
void

Definition at line 632 of file Core.php.

static _validateIdOrTag ( string ) [static, protected]

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

Throw an exception if a problem is found

Parameters:
string$stringCache id or tag
Exceptions:
Zend_Cache_Exception
Returns:
void

Definition at line 591 of file Core.php.

static _validateTagsArray ( tags ) [static, protected]

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

Throw an exception if a problem is found

Parameters:
array$tagsArray of tags
Exceptions:
Zend_Cache_Exception
Returns:
void

Definition at line 613 of file Core.php.

clean ( mode = 'all',
tags = array() 
)

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)

Parameters:
string$mode
array | string$tags
Exceptions:
Zend_Cache_Exception
Returns:
boolean True if ok

Definition at line 439 of file Core.php.

getBackend (  )

Returns the backend

Returns:
object backend object

Definition at line 190 of file Core.php.

getFillingPercentage (  )

Return the filling percentage of the backend storage

Returns:
int integer between 0 and 100

Definition at line 538 of file Core.php.

getIds (  )

Return an array of stored cache ids

Returns:
array array of stored cache ids (string)

Definition at line 498 of file Core.php.

getIdsMatchingTags ( tags = array() )

Return an array of stored cache ids which match given tags

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

Parameters:
array$tagsarray of tags
Returns:
array array of matching cache ids (string)

Definition at line 463 of file Core.php.

getIdsNotMatchingTags ( tags = array() )

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

Parameters:
array$tagsarray of tags
Returns:
array array of not matching cache ids (string)

Definition at line 482 of file Core.php.

getMetadatas ( id )

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
Parameters:
string$idcache id
Returns:
array array of metadatas (false if the cache id is not found)

Definition at line 557 of file Core.php.

getOption ( name )

Public frontend to get an option value

Parameters:
string$nameName of the option
Exceptions:
Zend_Cache_Exception
Returns:
mixed option value

Definition at line 230 of file Core.php.

getTags (  )

Return an array of stored tags

Returns:
array array of stored tags (string)

Definition at line 522 of file Core.php.

load ( id,
doNotTestCacheValidity = false,
doNotUnserialize = false 
)

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

Parameters:
string$idCache id
boolean$doNotTestCacheValidityIf set to true, the cache validity won't be tested
boolean$doNotUnserializeDo not serialize (even if automatic_serialization is true) => for internal use
Returns:
mixed|false Cached datas

Reimplemented in Zend_Cache_Frontend_File.

Definition at line 286 of file Core.php.

remove ( id )

Remove a cache

Parameters:
string$idCache id to remove
Returns:
boolean True if ok

Definition at line 411 of file Core.php.

save ( data,
id = null,
tags = array(),
specificLifetime = false,
priority = 8 
)

Save some data in a cache

Parameters:
mixed$dataData to put in cache (can be another type than string if automatic_serialization is on)
string$idCache id (if not set, the last cache id will be used)
array$tagsCache tags
int$specificLifetimeIf != false, set a specific lifetime for this cache record (null => infinite lifetime)
int$priorityinteger between 0 (very low priority) and 10 (maximum priority) used by some particular backends
Exceptions:
Zend_Cache_Exception
Returns:
boolean True if no problem

Definition at line 334 of file Core.php.

setBackend ( Zend_Cache_Backend backendObject )

Set the backend

Parameters:
object$backendObject
Exceptions:
Zend_Cache_Exception
Returns:
void

Definition at line 168 of file Core.php.

setConfig ( Zend_Config config )

Set options using an instance of type Zend_Config

Parameters:
Zend_Config$config
Returns:
Zend_Cache_Core

Definition at line 152 of file Core.php.

setLifetime ( newLifetime )

Force a new lifetime

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

Parameters:
int$newLifetimeNew lifetime (in seconds)
Returns:
void

Definition at line 270 of file Core.php.

setOption ( name,
value 
)

Public frontend to set an option

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

Parameters:
string$nameName of the option
mixed$valueValue of the option
Exceptions:
Zend_Cache_Exception
Returns:
void

Reimplemented in Zend_Cache_Frontend_Class, and Zend_Cache_Frontend_File.

Definition at line 205 of file Core.php.

test ( id )

Test if a cache is available for the given id

Parameters:
string$idCache id
Returns:
int|false Last modified time of cache entry if it is available, false otherwise

Reimplemented in Zend_Cache_Frontend_File.

Definition at line 312 of file Core.php.

touch ( id,
extraLifetime 
)

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

Parameters:
string$idcache id
int$extraLifetime
Returns:
boolean true if ok

Definition at line 573 of file Core.php.


Field Documentation

object $_backend = null [protected]

Backend Object

Definition at line 35 of file Core.php.

array $_directivesList = array('lifetime', 'logging', 'logger') [static, protected]

Array of options which have to be transfered to backend

Definition at line 94 of file Core.php.

boolean $_extendedBackend = false [protected]

True if the backend implements Zend_Cache_Backend_ExtendedInterface

Definition at line 115 of file Core.php.

$_options [protected]
Initial value:
 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
    )

Definition at line 77 of file Core.php.

array $_specificOptions = array() [protected]

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

Reimplemented in Zend_Cache_Frontend_Class, Zend_Cache_Frontend_File, Zend_Cache_Frontend_Function, and Zend_Cache_Frontend_Page.

Definition at line 101 of file Core.php.


The documentation for this class was generated from the following file: