API Documentation

Cache/Core.php

Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Cache
version
$Id: Core.php 22652 2010-07-21 04:30:24Z ramon $
Classes
Zend_Cache_Core

Description

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.

Zend_Cache_Core

copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Cache
Constants
BACKEND_NOT_SUPPORTS_TAG
BACKEND_NOT_IMPLEMENTS_EXTENDED_IF
Properties
$_backend
$_options
$_directivesList
$_specificOptions
$_lastId
$_extendedBackend
$_backendCapabilities
Methods
__construct
setConfig
setBackend
getBackend
setOption
getOption
_setOption
setLifetime
load
test
save
remove
clean
getIdsMatchingTags
getIdsNotMatchingTags
getIdsMatchingAnyTags
getIds
getTags
getFillingPercentage
getMetadatas
touch
_validateIdOrTag
_validateTagsArray
_loggerSanity
_log
_id

Description

Constants

BACKEND_NOT_SUPPORTS_TAG

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

Messages

Details

value
tags are not supported by the current backend

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'

Details

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

Properties

$_backend

Zend_Cache_Backend_Interface $_backend = 'null'

Backend Object

Details

$_backend
Zend_Cache_Backend_Interface
visibility
protected
default
null
final
false
static
false

$_backendCapabilities

array $_backendCapabilities = 'array'

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

Details

$_backendCapabilities
array
visibility
protected
default
array
final
false
static
false

$_directivesList

array $_directivesList = 'array'

Array of options which have to be transfered to backend

Details

$_directivesList
array
visibility
protected
default
array
final
false
static
true

$_extendedBackend

boolean $_extendedBackend = 'false'

True if the backend implements Zend_Cache_Backend_ExtendedInterface

Details

$_extendedBackend
boolean
visibility
protected
default
false
final
false
static
false

$_lastId

string $_lastId = 'null'

Last used cache id

Details

$_lastId
string
visibility
private
default
null
final
false
static
false

$_options

array $_options = 'array'

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)

Details

$_options
array
available options
visibility
protected
default
array
final
false
static
false

$_specificOptions

array $_specificOptions = 'array'

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

Details

$_specificOptions
array
visibility
protected
default
array
final
false
static
false

Methods

__construct

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

Constructor

Arguments
$options
arrayZend_Config
Associative array of options or Zend_Config instance
Details
visibility
public
final
false
static
false
throws

_id

_id( string $id ) : string

Make and return a cache id

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

Arguments
$id
string
Cache id
Output
string
Cache id (with or without prefix)
Details
visibility
protected
final
false
static
false

_log

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

Log a message at the WARN (4) priority.

Arguments
$message
string
$priority
Details
visibility
protected
final
false
static
false
throws

_loggerSanity

_loggerSanity( ) : void

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

Create a default log object if none is set.

Details
visibility
protected
final
false
static
false
throws

_setOption

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

Set an option

Arguments
$name
string
Name of the option
$value
mixed
Value of the option
Details
visibility
private
final
false
static
false
throws

_validateIdOrTag

_validateIdOrTag( string $string ) : void

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

Throw an exception if a problem is found

Arguments
$string
string
Cache id or tag
Details
visibility
protected
final
false
static
true
throws

_validateTagsArray

_validateTagsArray( array $tags ) : void

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

Throw an exception if a problem is found

Arguments
$tags
array
Array of tags
Details
visibility
protected
final
false
static
true
throws

clean

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

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)

Arguments
$mode
string
$tags
arraystring
Output
boolean
True if ok
Details
visibility
public
final
false
static
false
throws

getBackend

getBackend( ) : Zend_Cache_Backend

Returns the backend

Output
Zend_Cache_Backend
backend object
Details
visibility
public
final
false
static
false

getFillingPercentage

getFillingPercentage( ) : int

Return the filling percentage of the backend storage

Output
int
integer between 0 and 100
Details
visibility
public
final
false
static
false

getIds

getIds( ) : array

Return an array of stored cache ids

Output
array
array of stored cache ids (string)
Details
visibility
public
final
false
static
false

getIdsMatchingAnyTags

getIdsMatchingAnyTags( array $tags = array ) : array

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

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

Arguments
$tags
array
array of tags
Output
array
array of matching any cache ids (string)
Details
visibility
public
final
false
static
false

getIdsMatchingTags

getIdsMatchingTags( array $tags = array ) : array

Return an array of stored cache ids which match given tags

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

Arguments
$tags
array
array of tags
Output
array
array of matching cache ids (string)
Details
visibility
public
final
false
static
false

getIdsNotMatchingTags

getIdsNotMatchingTags( array $tags = array ) : 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

Arguments
$tags
array
array of tags
Output
array
array of not matching cache ids (string)
Details
visibility
public
final
false
static
false

getMetadatas

getMetadatas( string $id ) : array

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

Arguments
$id
string
cache id
Output
array
array of metadatas (false if the cache id is not found)
Details
visibility
public
final
false
static
false

getOption

getOption( string $name ) : mixed

Public frontend to get an option value

Arguments
$name
string
Name of the option
Output
mixed
option value
Details
visibility
public
final
false
static
false
throws

getTags

getTags( ) : array

Return an array of stored tags

Output
array
array of stored tags (string)
Details
visibility
public
final
false
static
false

load

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

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

Arguments
$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
Output
mixed|false
Cached datas
Details
visibility
public
final
false
static
false

remove

remove( string $id ) : boolean

Remove a cache

Arguments
$id
string
Cache id to remove
Output
boolean
True if ok
Details
visibility
public
final
false
static
false

save

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

Save some data in a cache

Arguments
$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
int
If != false, set a specific lifetime for this cache record (null => infinite lifetime)
$priority
int
integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
Output
boolean
True if no problem
Details
visibility
public
final
false
static
false
throws

setBackend

setBackend( Zend_Cache_Backend $backendObject ) : void

Set the backend

Arguments
$backendObject
Zend_Cache_Backend
Details
visibility
public
final
false
static
false
throws

setConfig

setConfig( Zend_Config $config ) : Zend_Cache_Core

Set options using an instance of type Zend_Config

Arguments
$config
Zend_Config
Details
visibility
public
final
false
static
false

setLifetime

setLifetime( int $newLifetime ) : void

Force a new lifetime

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

Arguments
$newLifetime
int
New lifetime (in seconds)
Details
visibility
public
final
false
static
false

setOption

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

Public frontend to set an option

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

Arguments
$name
string
Name of the option
$value
mixed
Value of the option
Details
visibility
public
final
false
static
false
throws

test

test( string $id ) : int|false

Test if a cache is available for the given id

Arguments
$id
string
Cache id
Output
int|false
Last modified time of cache entry if it is available, false otherwise
Details
visibility
public
final
false
static
false

touch

touch( string $id, int $extraLifetime ) : boolean

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

Arguments
$id
string
cache id
$extraLifetime
int
Output
boolean
true if ok
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.