CDummyCache

CDbHttpSession

Yii Framework v1.1.10 类参考

CDummyCache

system.caching
继承 class CDummyCache » CApplicationComponent » CComponent
实现 IApplicationComponent, ICache, ArrayAccess
源自 1.0
版本 $Id: CDummyCache.php 3515 2011-12-28 12:29:24Z mdomba $
源码 framework/caching/CDummyCache.php
CDummyCache是一个占位缓存组件。

CDummyCache不缓存任何数据。它使得我们总是可以配置一个 缓存应用组件而不必检查Yii::app()->cache是否为null。 将CDummyCache替换为其他缓存组件,可以快速的 在无缓存模式和缓存模式之间切换。

公共属性

隐藏继承属性

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

公共方法

隐藏继承方法

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

属性详细

keyPrefix 属性
public string $keyPrefix;

加在每个缓存键名前的字符串以保证键名是唯一的。默认值是application ID

方法详细

add() 方法
public boolean add(string $id, mixed $value, integer $expire=0, ICacheDependency $dependency=NULL)
$id string 用以甄别缓存值的键名
$value mixed 要缓存的值
$expire integer 以秒为单位的数值,表示缓存的过期时间。为0则永不过期。
$dependency ICacheDependency 缓存项的依赖项。若依赖项改变,缓存项会被标志为无效。
{return} boolean 成功存储到缓存中则返回true,否则返回false
源码: framework/caching/CDummyCache.php#95 (显示)
public function add($id,$value,$expire=0,$dependency=null)
{
    return 
true;
}

仅仅在甄别缓存值的键名不存在的情况下,往缓存中存储值。 若缓存中已有该键名则什么也不做。

delete() 方法
public boolean delete(string $id)
$id string 要删除值的键名
{return} boolean 如果删除期间没有发生错误
源码: framework/caching/CDummyCache.php#105 (显示)
public function delete($id)
{
    return 
true;
}

从缓存中删除指定键名对应的值

flush() 方法
public boolean flush()
{return} boolean 如果清空操作成功执行。
源码: framework/caching/CDummyCache.php#116 (显示)
public function flush()
{
    return 
true;
}

删除所有缓存值。 若缓存被多个应用程序共享,务必小心执行此操作。

get() 方法
public mixed get(string $id)
$id string 用以甄别缓存值的键名
{return} mixed 缓存中存储的值,若该值不在缓存中、已过期或依赖项改变时则返回false。
源码: framework/caching/CDummyCache.php#47 (显示)
public function get($id)
{
    return 
false;
}

从缓存中检索一个匹配指定键名的值。

init() 方法
public void init()
源码: framework/caching/CDummyCache.php#35 (显示)
public function init()
{
    
parent::init();
    if(
$this->keyPrefix===null)
        
$this->keyPrefix=Yii::app()->getId();
}

初始化应用程序组件。 通过设置默认缓存键名前缀,该方法重写了父类方法的实现。

mget() 方法
public array mget(array $ids)
$ids array 用以甄别缓存值的键名列表
{return} array 以指定键名列表对应的缓存值列表。 以(键名,值)对的形式返回数组。 若某值不在缓存中或已过期则数组中对应的值为false。
源码: framework/caching/CDummyCache.php#62 (显示)
public function mget($ids)
{
    
$results=array();
    foreach(
$ids as $id)
        
$results[$id]=false;
    return 
$results;
}

从缓存中检索出多个匹配指定键名的值。 某些缓存(诸如memcache,apc)允许一次性检索多个值, 这可以提高性能,因为它降低了通信成本。 在缓存本身不支持此功能的情况下,它会用这种方法模拟。

offsetExists() 方法
public boolean offsetExists(string $id)
$id string 用以甄别缓存值的键名
{return} boolean
源码: framework/caching/CDummyCache.php#127 (显示)
public function offsetExists($id)
{
    return 
false;
}

返回指定键名的缓存条目是否存在。 该方法是接口ArrayAccess中要求的。

offsetGet() 方法
public mixed offsetGet(string $id)
$id string 用以甄别缓存值的键名
{return} mixed 缓存中存储的值,若该值不在缓存中或者已过期则返回false。
源码: framework/caching/CDummyCache.php#138 (显示)
public function offsetGet($id)
{
    return 
false;
}

从缓存中检索一个匹配指定键名的值。 该方法是接口ArrayAccess中要求的。

offsetSet() 方法
public void offsetSet(string $id, mixed $value)
$id string 用以甄别缓存值的键名
$value mixed 要缓存的值
源码: framework/caching/CDummyCache.php#151 (显示)
public function offsetSet($id$value)
{
}

往缓存中存储一个用键名区分的值。 若缓存中已经包含该键名,则之前的缓存值 会被新的替换掉。使用set()方法来添加过期时间和依赖项。 该方法是接口ArrayAccess中要求的。

offsetUnset() 方法
public boolean offsetUnset(string $id)
$id string 要删除值的键名
{return} boolean 如果删除期间没有发生错误
源码: framework/caching/CDummyCache.php#161 (显示)
public function offsetUnset($id)
{
}

从缓存中删除指定键名对应的值 该方法是接口ArrayAccess中要求的。

set() 方法
public boolean set(string $id, mixed $value, integer $expire=0, ICacheDependency $dependency=NULL)
$id string 用以甄别缓存值的键名
$value mixed 要缓存的值
$expire integer 以秒为单位的数值,表示缓存的过期时间。为0则永不过期。
$dependency ICacheDependency 缓存项的依赖项。若依赖项改变,缓存项会被标志为无效。
{return} boolean 成功存储到缓存中则返回true,否则返回false
源码: framework/caching/CDummyCache.php#81 (显示)
public function set($id,$value,$expire=0,$dependency=null)
{
    return 
true;
}

根据一个用以甄别的键名往缓存中存储一个值。 若缓存中已经包含该键名,则之前的缓存值 和过期时间会被新的替换掉。

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