phpDocumentor strategy
[ class tree: strategy ] [ index: strategy ] [ all elements ]

Class: WindDbCache

Source Location: /cache/strategy/WindDbCache.php

Class WindDbCache

Class Overview

Db缓存策略实现

Db缓存允许用户配置一个缓存数据表,将缓存数据保存到缓存表中. 提供对方访问接口如下:

它接收如下配置:

  1.      array(
  2.          'table-name' => 'pw_cache',    //缓存的表名
  3.         'field-key' => 'key',    //缓存key的字段名,唯一键值
  4.         'field-value' => 'value',    //缓存数据存储的字段名
  5.         'field-expire' => 'expire',    //缓存数据的过期时间字段名,为int类型,默认为0
  6.         'security-code' => '',    //继承自AbstractWindCache,安全码配置
  7.         'key-prefix' => '',     //继承自AbstractWindCache,缓存key前缀
  8.         'expires' => '0',    //继承自AbstractWindCache,缓存过期时间配置
  9.     )
Db缓存的使用:
1、像使用普通类库一样使用该组件:
  1.   Wind::import('WIND:cache.strategy.WindDbCache');
  2.      $cache new WindDbCache($dbHandlerarray('table-name' => 'pw_cache''field-key' => 'key''field-value' => 'value''field-expire' => '0'));
  3.   $cache->set('name''windDbTest');
<note>注意:需要传入dbHandler(数据库链接对象)</note> 2、采用组件配置的方式,通过组件机制调用 在应用配置的components组件配置块中,配置dbCache(该名字将决定调用的时候使用的组件名字):
  'dbCache' => array(
      'path' => 'WIND:cache.strategy.WindDbCache',
        'scope' => 'singleton',
        'properties' => array(
            'connection' => array('ref' => 'db');
      ),
        'config' => array(
            'table-name' => 'pw_cache',
            'field-key' => 'key',
            'field-value' => 'value',
            'field-expire' => 'expire',
            'security-code' => '',
             'key-prefix' => '',
          'expires' => '0',
        ),
  ),
在应用中可以通过如下方式获得dbCache对象:
  1.  $cache Wind::getApp()->getComponent('dbCache');    //dbCache的名字来自于组件配置中的名字
  2.  $cache->set('name''test');
<note>注意:组件配置需要配置属性(preperties),connection其值为db组件的一个引用</note>

the last known user to change this file in the repository <LastChangedBy: xiaoxiao >

Located in /cache/strategy/WindDbCache.php [line 71]

WindModule
   |
   --AbstractWindCache
      |
      --WindDbCache
Author(s): Information Tags:
Version:  $Id: WindDbCache.php 2973 2011-10-15 19:22:48Z yishuo $
Copyright:  ©2003-2103 phpwind.com
License:  http://www.windframework.com

Properties

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From WindModule

WindModule::$_config
WindModule::$_proxy
WindModule::$_typeValidation

Inherited From AbstractWindCache

AbstractWindCache::add()
增加一个条目到缓存服务器
AbstractWindCache::addValue()
执行添加操作
AbstractWindCache::batchDelete()
通过key批量删除缓存数据
AbstractWindCache::batchGet()
通过key批量获取缓存数据
AbstractWindCache::buildData()
构造保存的数据
AbstractWindCache::buildSecurityKey()
将数据key计算生成安全的key
AbstractWindCache::clear()
清楚缓存,过期及所有缓存
AbstractWindCache::decrement()
将元素的值减小value
AbstractWindCache::delete()
删除缓存数据
AbstractWindCache::deleteValue()
需要实现的删除操作
AbstractWindCache::formatData()
格式化输出
AbstractWindCache::get()
根据缓存key获取指定缓存
AbstractWindCache::getExpire()
返回过期时间设置
AbstractWindCache::getKeyPrefix()
返回缓存Key值前缀
AbstractWindCache::getSecurityCode()
获得缓存key计算中加入的安全码
AbstractWindCache::getValue()
执行获取操作
AbstractWindCache::hasChanged()
判断数据是否已经被更新
AbstractWindCache::increment()
将指定元素的值增加value
AbstractWindCache::set()
设置缓存 如果key不存在,添加缓存;否则,将会替换已有key的缓存。
AbstractWindCache::setConfig()
设置配置信息
AbstractWindCache::setExpire()
设置缓存过期时间
AbstractWindCache::setKeyPrefix()
设置key前缀
AbstractWindCache::setSecurityCode()
设置缓存key计算中加入的安全码
AbstractWindCache::setValue()
执行设置操作

Inherited From WindModule

WindModule::getConfig()
根据配置名取得相应的配置
WindModule::getRequest()
返回当前应用的WindHttpRequest对象
WindModule::getResponse()
返回当前应用的WindHttpResponse对象
WindModule::getSystemFactory()
返回当前应用的WindFactory对象
WindModule::setConfig()
设置类配置
WindModule::setDelayAttributes()
设置延迟加载类属性相关组件配置信息
WindModule::toArray()
返回该对象的数组类型
WindModule::writeTableCloneProperty()
类对象clone白名单
WindModule::__call()
重载了魔术方法__call
WindModule::__clone()
重载魔术方法__clone
WindModule::__get()
重载了魔术方法__get
WindModule::__set()
重载了魔术方法__set

Inherited From AbstractWindCache

AbstractWindCache::DATA
AbstractWindCache::DEPENDENCY
AbstractWindCache::DEPENDENCYCLASS
AbstractWindCache::EXPIRE
AbstractWindCache::STORETIME

[ Top ]
Method Summary
WindDbCache   __construct()   构造函数
void   addValue()  
void   batchDelete()  
void   batchGet()  
int   clear()   清除缓存数据
void   deleteValue()  
void   getValue()  
void   setConfig()  
void   setConnection()   设置链接对象
void   setValue()  

[ Top ]
Properties
WindConnection   $connection [line 78]

链接句柄

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 116]

  WindDbCache __construct( [WindConnection $connection = null], [array $config = array()]  )

构造函数

初始化数据

Parameters:
WindConnection   $connection:  数据库链接对象,缺省值为null
array   $config:  缓存的配置文件,缺省值为array()

API Tags:
Access:  public


[ Top ]
addValue  [line 131]

  void addValue( $key, $value, [ $expire = 0]  )

Parameters:
   $key: 
   $value: 
   $expire: 

API Tags:
Access:  protected


Redefinition of:
AbstractWindCache::addValue()
执行添加操作

[ Top ]
batchDelete  [line 172]

  void batchDelete( array $keys  )

Parameters:
array   $keys: 

API Tags:
Access:  public


Redefinition of:
AbstractWindCache::batchDelete()
通过key批量删除缓存数据

[ Top ]
batchGet  [line 147]

  void batchGet( array $keys  )

Parameters:
array   $keys: 

API Tags:
Access:  public


Redefinition of:
AbstractWindCache::batchGet()
通过key批量获取缓存数据

[ Top ]
clear  [line 191]

  int clear( [boolean $expireOnly = true]  )

清除缓存数据

  • 如果$expireOnly=true,则将只删除过期的数据。
  • 如果$expireOnly=false,则将删除所有缓存数据。

Parameters:
boolean   $expireOnly:  如果删除过期数据则设置为true,如果全部缓存都删除则为false,缺省值为true

API Tags:
Access:  public


Redefinition of:
AbstractWindCache::clear()
清楚缓存,过期及所有缓存

[ Top ]
deleteValue  [line 164]

  void deleteValue( $key  )

Parameters:
   $key: 

API Tags:
Access:  protected


Redefinition of:
AbstractWindCache::deleteValue()
需要实现的删除操作

[ Top ]
getValue  [line 138]

  void getValue( $key  )

Parameters:
   $key: 

API Tags:
Access:  protected


Redefinition of:
AbstractWindCache::getValue()
执行获取操作

[ Top ]
setConfig  [line 203]

  void setConfig( $config  )

Parameters:
   $config: 

API Tags:
Access:  public


Redefinition of:
AbstractWindCache::setConfig()
设置配置信息

[ Top ]
setConnection  [line 216]

  void setConnection( WindConnection $connection  )

设置链接对象

Parameters:
WindConnection   $connection: 

API Tags:
Access:  public


[ Top ]
setValue  [line 124]

  void setValue( $key, $value, [ $expire = 0]  )

Parameters:
   $key: 
   $value: 
   $expire: 

API Tags:
Access:  protected


Redefinition of:
AbstractWindCache::setValue()
执行设置操作

[ Top ]

Documentation generated on Fri, 30 Mar 2012 11:43:31 +0800 by phpDocumentor 1.4.4