system system.base system.caching system.caching.dependencies system.collections system.console system.db system.db.ar system.db.schema system.db.schema.cubrid system.db.schema.mssql system.db.schema.mysql system.db.schema.oci system.db.schema.pgsql system.db.schema.sqlite system.gii system.i18n system.i18n.gettext system.logging system.test system.utils system.validators system.web system.web.actions system.web.auth system.web.filters system.web.form system.web.helpers system.web.renderers system.web.services system.web.widgets system.web.widgets.captcha system.web.widgets.pagers zii.behaviors zii.widgets zii.widgets.grid zii.widgets.jui

ICache

system.caching
继承 interface ICache
子类 CApcCache, CCache, CDbCache, CDummyCache, CEAcceleratorCache, CFileCache, CMemCache, CRedisCache, CWinCache, CXCache, CZendDataCache
可用自 1.0
源码 framework/base/interfaces.php
ICache is the interface that must be implemented by cache components.

This interface must be implemented by classes supporting caching feature.

公共方法

隐藏继承的方法

方法描述被定义在
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
mget() Retrieves multiple values from cache with the specified keys. ICache
set() Stores a value identified by a key into cache. ICache

方法详情

add() 方法
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
源码: framework/base/interfaces.php#83 (显示)
public function add($id,$value,$expire=0,$dependency=null);

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() 方法
abstract public boolean delete(string $id)
$id string the key of the value to be deleted
{return} boolean whether the deletion is successful
源码: framework/base/interfaces.php#89 (显示)
public function delete($id);

Deletes a value with the specified key from cache

flush() 方法
abstract public boolean flush()
{return} boolean whether the flush operation was successful.
源码: framework/base/interfaces.php#95 (显示)
public function flush();

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

get() 方法
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.
源码: framework/base/interfaces.php#50 (显示)
public function get($id);

Retrieves a value from cache with a specified key.

mget() 方法
abstract public array mget(array $ids)
$ids array list of keys identifying the cached values
{return} array list of cached values corresponding to the specified keys. The array is returned in terms of (key,value) pairs. If a value is not cached or expired, the corresponding array value will be false.
源码: framework/base/interfaces.php#61 (显示)
public function mget($ids);

Retrieves multiple values from cache with the specified keys. Some caches (such as memcache, apc) allow retrieving multiple cached values at one time, which may improve the performance since it reduces the communication cost. In case a cache doesn't support this feature natively, it will be simulated by this method.

set() 方法
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
源码: framework/base/interfaces.php#73 (显示)
public function set($id,$value,$expire=0,$dependency=null);

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.