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

Class: WindFileCache

Source Location: /cache/strategy/WindFileCache.php

Class WindFileCache

Class Overview

file缓存策略实现

提供对方访问接口如下:

它接收如下配置:
  1.  array(
  2.  'dir' => 'data',    //缓存文件存放的目录,注意可读可写
  3.  'suffix' => 'txt',    //缓存文件的后缀,默认为txt后缀
  4.  'dir-level' => '0',    //缓存文件存放目录的子目录长度,默认为0不分子目录
  5.  'security-code' => '',    //继承自AbstractWindCache,安全码配置
  6.  'key-prefix' => '',     //继承自AbstractWindCache,缓存key前缀
  7.  'expires' => '0',    //继承自AbstractWindCache,缓存过期时间配置
  8.  )
使用方法:
1、您可以像使用普通类库一样使用该组件:
  1.  Wind::import('WIND:cache.strategy.WindFileCache');
  2.  $cache new WindFileCache();
  3.  $cache->setConfig(array('dir' => 'data''suffix' => 'php'));
  4.  $cache->set('name''fileCacheTest');
2、采用组件配置的方式,通过组件机制调用 在应用配置的components组件配置块中,配置fileCache(该名字将决定调用的时候使用的组件名字):
 'fileCache' => array(
 'path' => 'WIND:cache.strategy.WindFileCache',
 'scope' => 'singleton',
 'config' => array(
 'dir' => 'data',
 'suffix' => 'txt',
 'dir-level' => '0',
 'security-code' => '',
 'key-prefix' => '',
 'expires' => '0',
 ),
 ),
在应用中可以通过如下方式获得dbCache对象:
  1.  $fileCache Wind::getApp()->getComponent('fileCache');    //dbCache的名字来自于组件配置中的名字

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

Located in /cache/strategy/WindFileCache.php [line 63]

WindModule
   |
   --AbstractWindCache
      |
      --WindFileCache
Author(s): Information Tags:
Version:  $Id: WindFileCache.php 3228 2011-12-02 06:49:38Z yishuo $
Copyright:  ©2003-2103 phpwind.com
License:  http://www.windframework.com

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
void   addValue()  
string   buildSecurityKey()   根据用户key计算获取真是缓存文件
void   clear()  
void   deleteValue()  
int   getCacheDirectoryLevel()   返回缓存存放的目录下子目录的长度
void   getValue()  
void   setCacheDir()   设置缓存目录
void   setCacheDirectoryLevel()   设置缓存存放的目录下子目录的长度
void   setCacheFileSuffix()   设置缓存文件的后缀
void   setConfig()  
void   setValue()  

[ Top ]
Methods
addValue  [line 105]

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

Parameters:
   $key: 
   $value: 
   $expire: 

API Tags:
Access:  protected


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

[ Top ]
buildSecurityKey  [line 153]

  string buildSecurityKey( string $key  )

根据用户key计算获取真是缓存文件

缓存key在安全处理之后,判断该key是否已经被访问过

  • 如果被访问过,则直接返回该真实缓存文件
  • 没有访问过,则将会进入计算流程.
    1. 如果用该组件配置了缓存子目录的长度n:
      • 获得缓存key的md5值的0~n的子字串作为子缓存目录;
      • 将缓存文件存放在该缓存子目录下.同时将该缓存文件的新路径保存到已访问的缓存路径列表中,供下次直接调用.
    2. 如果没有配置缓存子目录长度,则直接将该文件缓存在缓存根目录下,同时也将该缓存文件路径保存在已访问的缓存路径列表中.

Parameters:
string   $key:  用户的缓存文件key

API Tags:
Return:  真实的缓存文件
Access:  protected


Redefinition of:
AbstractWindCache::buildSecurityKey()
将数据key计算生成安全的key

[ Top ]
clear  [line 127]

  void clear( )


API Tags:
Access:  public


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

[ Top ]
deleteValue  [line 120]

  void deleteValue( $key  )

Parameters:
   $key: 

API Tags:
Access:  protected


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

[ Top ]
getCacheDirectoryLevel  [line 236]

  int getCacheDirectoryLevel( )

返回缓存存放的目录下子目录的长度

该值将会决定缓存目录下子缓存目录的长度,最小为0(不建子目录),最大为32(md5值最长32),缺省为0


API Tags:
Access:  public


[ Top ]
getValue  [line 112]

  void getValue( $key  )

Parameters:
   $key: 

API Tags:
Access:  protected


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

[ Top ]
setCacheDir  [line 187]

  void setCacheDir( string $dir  )

设置缓存目录

Parameters:
string   $dir:  缓存目录,必须是可写可读权限

API Tags:
Access:  public


[ Top ]
setCacheDirectoryLevel  [line 225]

  void setCacheDirectoryLevel( int $cacheDirectoryLevel  )

设置缓存存放的目录下子目录的长度

Parameters:
int   $cacheDirectoryLevel:  该值将会决定缓存目录下子缓存目录的长度,最小为0(不建子目录),最大为32(md5值最长32),缺省为0

API Tags:
Access:  public


[ Top ]
setCacheFileSuffix  [line 207]

  void setCacheFileSuffix( string $cacheFileSuffix  )

设置缓存文件的后缀

Parameters:
string   $cacheFileSuffix:  缓存文件的后缀,默认为txt

API Tags:
Access:  public


[ Top ]
setConfig  [line 243]

  void setConfig( $config  )

Parameters:
   $config: 

API Tags:
Access:  public


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

[ Top ]
setValue  [line 98]

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