CZendDataCache

CDbHttpSession

Yii Framework v1.1.10 类参考

CZendDataCache

system.caching
继承 class CZendDataCache » CCache » CApplicationComponent » CComponent
实现 ArrayAccess, ICache, IApplicationComponent
版本 $Id: CZendDataCache.php 3515 2011-12-28 12:29:24Z mdomba $
源码 framework/caching/CZendDataCache.php
CZendDataCache基于ZendServer 提供的Zend Data Cache实现一个缓存应用模块。

PHP扩展Zend Data Cache必须加载以使用这个应用程序组件。

See CCache manual for common cache operations that are supported by CZendDataCache.

公共属性

隐藏继承属性

属性类型描述定义在
behaviors array 这个应用组件附加的行为。 这此行为将在应用组件调用init时附加在应用组件上。 请参照CModel::behaviors如何指定此属性值。 CApplicationComponent
isInitialized boolean 检查应用组件是否已经初始化。 CApplicationComponent
keyPrefix string 加在每个缓存键名前的字符串以保证键名是唯一的。默认值是application ID CCache

公共方法

隐藏继承方法

方法描述定义在
__call() 如果类中没有调的方法名,则调用这个方法。 CComponent
__get() 返回一个属性值、一个事件处理程序列表或一个行为名称。 CComponent
__isset() 检查一个属性是否为null。 CComponent
__set() 设置一个组件的属性值。 CComponent
__unset() 设置一个组件的属性为null。 CComponent
add() 仅仅在甄别缓存值的键名不存在的情况下,往缓存中存储值。 CCache
asa() 返回这个名字的行为对象。 CComponent
attachBehavior() 附加一个行为到组件。 CComponent
attachBehaviors() 附加一个行为列表到组件。 CComponent
attachEventHandler() 为事件附加一个事件处理程序。 CComponent
canGetProperty() 确定属性是否可读。 CComponent
canSetProperty() 确定属性是否可写。 CComponent
delete() 从缓存中删除指定键名对应的值 CCache
detachBehavior() 从组件中分离一个行为。 CComponent
detachBehaviors() 从组件中分离所有行为。 CComponent
detachEventHandler() 分离一个存在的事件处理程序。 CComponent
disableBehavior() 禁用一个附加行为。 CComponent
disableBehaviors() 禁用组件附加的所有行为。 CComponent
enableBehavior() 启用一个附加行为。 CComponent
enableBehaviors() 启用组件附加的所有行为。 CComponent
evaluateExpression() 计算一个PHP表达式,或根据组件上下文执行回调。 CComponent
flush() 删除所有缓存值。 CCache
get() 从缓存中检索一个匹配指定键名的值。 CCache
getEventHandlers() 返回一个事件的附加处理程序列表。 CComponent
getIsInitialized() 检查应用组件是否已经初始化。 CApplicationComponent
hasEvent() 确定一个事件是否定义。 CComponent
hasEventHandler() 检查事件是否有附加的处理程序。 CComponent
hasProperty() 确定属性是否被定义。 CComponent
init() 初始化应用程序组件。 CZendDataCache
mget() 从缓存中检索出多个匹配指定键名的值。 CCache
offsetExists() 返回指定键名的缓存条目是否存在。 CCache
offsetGet() 从缓存中检索一个匹配指定键名的值。 CCache
offsetSet() 往缓存中存储一个用键名区分的值。 CCache
offsetUnset() 从缓存中删除指定键名对应的值 CCache
raiseEvent() 发起一个事件。 CComponent
set() 根据一个用以甄别的键名往缓存中存储一个值。 CCache

受保护方法

隐藏继承方法

方法描述定义在
addValue() 仅仅在甄别缓存值的键名不存在的情况下,往缓存中存储值。 CZendDataCache
deleteValue() 从缓存中删除指定键名对应的值 CZendDataCache
flushValues() 删除所有缓存值。 CZendDataCache
generateUniqueKey() CCache
getValue() 从缓存中检索一个匹配指定键名的值。 CZendDataCache
getValues() 从缓存中检索出多个匹配指定键名的值。 CCache
setValue() 往缓存中存储一个用键名区分的值。 CZendDataCache

方法详细

addValue() 方法
protected boolean addValue(string $key, string $value, integer $expire)
$key string 用以甄别缓存值的键名
$value string 要缓存的值
$expire integer 以秒为单位的数值,表示缓存的过期时间。为0则永不过期。
{return} boolean 成功存储到缓存中则返回true,否则返回false
源码: framework/caching/CZendDataCache.php#73 (显示)
protected function addValue($key,$value,$expire)
{
    return (
NULL === zend_shm_cache_fetch($key)) ? $this->setValue($key,$value,$expire) : false;
}

仅仅在甄别缓存值的键名不存在的情况下,往缓存中存储值。 这是在父类中定义的方法的具体实现。

deleteValue() 方法
protected boolean deleteValue(string $key)
$key string 要删除值的键名
{return} boolean 如果删除期间没有发生错误
源码: framework/caching/CZendDataCache.php#84 (显示)
protected function deleteValue($key)
{
    return 
zend_shm_cache_delete($key);
}

从缓存中删除指定键名对应的值 这是在父类中定义的方法的具体实现。

flushValues() 方法 (可用自 v1.1.5)
protected boolean flushValues()
{return} boolean 如果清空操作成功执行。
源码: framework/caching/CZendDataCache.php#95 (显示)
protected function flushValues()
{
    return 
zend_shm_cache_clear();
}

删除所有缓存值。 这是在父类中定义的方法的具体实现。

getValue() 方法
protected string getValue(string $key)
$key string 用以甄别缓存值的唯一键名
{return} string 缓存中存储的值,如果该值不存在或者已过期则返回false。
源码: framework/caching/CZendDataCache.php#44 (显示)
protected function getValue($key)
{
    
$result zend_shm_cache_fetch($key);
    return 
$result !== NULL $result false;
}

从缓存中检索一个匹配指定键名的值。 这是在父类中定义的方法的具体实现。

init() 方法
public void init()
源码: framework/caching/CZendDataCache.php#31 (显示)
public function init()
{
    
parent::init();
    if(!
function_exists('zend_shm_cache_store'))
        throw new 
CException(Yii::t('yii','CZendDataCache requires PHP Zend Data Cache extension to be loaded.'));
}

初始化应用程序组件。 该方法在接口IApplicationComponent中有要求。 它检查Zend Data Cache是否可用。It checks the availability of Zend Data Cache.

setValue() 方法
protected boolean setValue(string $key, string $value, integer $expire)
$key string 用以甄别缓存值的键名
$value string 要缓存的值
$expire integer 以秒为单位的数值,表示缓存的过期时间。为0则永不过期。
{return} boolean 成功存储到缓存中则返回true,否则返回false
源码: framework/caching/CZendDataCache.php#59 (显示)
protected function setValue($key,$value,$expire)
{
    return 
zend_shm_cache_store($key,$value,$expire);
}

往缓存中存储一个用键名区分的值。 这是在父类中定义的方法的具体实现。

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.