ICache

Package system.caching
Inheritance interface ICache
Subclasses CApcCache, CCache, CDbCache, CMemCache, CXCache
Since 1.0
Version $Id: interfaces.php 548 2009-01-20 04:27:09Z qiang.xue $
ICache is the interface that must be implemented by cache components.

This interface must be implemented by classes supporting caching feature.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
add() Stores a value identified by a key into cache if the cache does not contain this key. ICache
delete() Deletes a value with the specified key from cache ICache
flush() Deletes all values from cache. ICache
get() Retrieves a value from cache with a specified key. ICache
set() Stores a value identified by a key into cache. ICache

Method Details

add() method
abstract public boolean add(string $id, mixed $value, integer $expire=0, ICacheDependency $dependency=NULL)
$id string the key identifying the value to be cached
$value mixed the value to be cached
$expire integer the number of seconds in which the cached value will expire. 0 means never expire.
$dependency ICacheDependency dependency of the cached item. If the dependency changes, the item is labelled invalid.
{return} boolean true if the value is successfully stored into cache, false otherwise

Stores a value identified by a key into cache if the cache does not contain this key. Nothing will be done if the cache already contains the key.

delete() method
abstract public boolean delete(string $id)
$id string the key of the value to be deleted
{return} boolean whether the deletion is successful

Deletes a value with the specified key from cache

flush() method
abstract public void flush()

Deletes all values from cache. Be careful of performing this operation if the cache is shared by multiple applications.

get() method
abstract public mixed get(string $id)
$id string a key identifying the cached value
{return} mixed the value stored in cache, false if the value is not in the cache or expired.

Retrieves a value from cache with a specified key.

set() method
abstract public boolean set(string $id, mixed $value, integer $expire=0, ICacheDependency $dependency=NULL)
$id string the key identifying the value to be cached
$value mixed the value to be cached
$expire integer the number of seconds in which the cached value will expire. 0 means never expire.
$dependency ICacheDependency dependency of the cached item. If the dependency changes, the item is labelled invalid.
{return} boolean true if the value is successfully stored into cache, false otherwise

Stores a value identified by a key into cache. If the cache already contains such a key, the existing value and expiration time will be replaced with the new ones.