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

Class: WindMemCache

Source Location: /cache/strategy/WindMemCache.php

Class WindMemCache

Class Overview

memCache策略实现

memCache缓存允许将缓存保存到memCache内存缓存中. 提供对方访问接口如下:

它接收如下配置:

  1.  array(
  2.  'security-code' => '',    //继承自AbstractWindCache,安全码配置.
  3.  'key-prefix' => '',     //继承自AbstractWindCache,缓存key前缀.
  4.  'expires' => '0',    //继承自AbstractWindCache,缓存过期时间配置.
  5.  'compress' => '0',    //压缩等级,默认为0
  6.  'servers' => array(
  7.  'host' => array(
  8.  'host'=>'localhost',    //要连接的memcached服务端监听的主机位置.
  9.  'port'=>11211,    //要连接的memcached服务端监听的端口.
  10.  'pconn'=>true,    //控制是否使用持久化连接,默认true.
  11.  'weight' => 1,    //为此服务器创建的桶的数量,用来控制此服务器被选中的权重,单个服务器被选中的概率是相对于所有服务器weight总和而言的.
  12.  'timeout' => 1,    //连接持续(超时)时间(单位秒),默认值1秒.
  13.  'retry' => 15,    //服务器连接失败时重试的间隔时间,默认值15秒.
  14.  'status' => true,    //控制此服务器是否可以被标记为在线状态.
  15.  'fcallback' => null,    //允许用户指定一个运行时发生错误后的回调函数
  16.  ),
  17.  ),
  18.  )
使用方法:
1、按照普通的调用类库的方式去调用:
  1.  Wind::import("WIND:cache.strategy.WindMemCache");
  2.  $cache new WindMemCache();
  3.  $cache->setConfig(array('host' => 'localhost''port' => 11211));
  4.  $cache->set('name''test');
2、采用组件配置的方式,通过组件机制调用 在应用配置的components组件配置块中,配置memCache(该名字将决定调用的时候使用的组件名字):
  1.  'memCache' => array(
  2.  'path' => 'WIND:cache.strategy.WindMemCache',
  3.  'config' array(
  4.  'security-code' => '',
  5.  'key-prefix' => '',
  6.  'expires' => '0',
  7.  'compress' => '0',
  8.  'servers' => array(
  9.  'host1' => array(
  10.  'host'=>'localhost',
  11.  'port'=>11211,
  12.  'pconn'=>true,
  13.  'weight' => 1,
  14.  'timeout' => 15,
  15.  'retry' => 15,
  16.  'status' => true,
  17.  'fcallback' => null,
  18.  ),
  19.  ),
  20.  ),
  21.  ),
如果含有多个memCache主机,可以设置多组host在config中,如host1,host2,其key值也可以自定义.

<note>注意:要使用该组件需要安装memcache扩展库.</note>

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

Located in /cache/strategy/WindMemCache.php [line 83]

WindModule
   |
   --AbstractWindCache
      |
      --WindMemCache
Author(s): Information Tags:
Version:  $Id: WindMemCache.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 ]
Property Summary
int   $compress   是否对缓存采取压缩存储
WindMemcache   $memcache   memcache缓存操作句柄

[ Top ]
Method Summary
WindMemCache   __construct()   构造函数
void   addValue()  
void   clear()  
void   decrement()  
void   deleteValue()  
void   getValue()  
void   increment()  
void   setConfig()  
void   setValue()  

[ Top ]
Properties
int   $compress = 0 [line 104]

是否对缓存采取压缩存储

API Tags:
Access:  protected


[ Top ]
WindMemcache   $memcache = null [line 90]

memcache缓存操作句柄

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 114]

  WindMemCache __construct( )

构造函数

判断是否有支持memCache,如果没有安装扩展库将会抛出异常,
首先尝试使用memcached扩展,如果然后尝试创建memcache


API Tags:
Access:  public

Information Tags:
Throws:  WindCacheException 如果没有安装memcache扩展则抛出异常

[ Top ]
addValue  [line 137]

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

Parameters:
   $key: 
   $value: 
   $expires: 

API Tags:
Access:  protected


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

[ Top ]
clear  [line 159]

  void clear( )


API Tags:
Access:  public


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

[ Top ]
decrement  [line 173]

  void decrement( $key, [ $step = 1]  )

Parameters:
   $key: 
   $step: 

API Tags:
Access:  public


Redefinition of:
AbstractWindCache::decrement()
将元素的值减小value

[ Top ]
deleteValue  [line 152]

  void deleteValue( $key  )

Parameters:
   $key: 

API Tags:
Access:  protected


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

[ Top ]
getValue  [line 145]

  void getValue( $key  )

Parameters:
   $key: 

API Tags:
Access:  protected


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

[ Top ]
increment  [line 166]

  void increment( $key, [ $step = 1]  )

Parameters:
   $key: 
   $step: 

API Tags:
Access:  public


Redefinition of:
AbstractWindCache::increment()
将指定元素的值增加value

[ Top ]
setConfig  [line 180]

  void setConfig( $config  )

Parameters:
   $config: 

API Tags:
Access:  public


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

[ Top ]
setValue  [line 129]

  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:37 +0800 by phpDocumentor 1.4.4