Book/yac-Phpdoc专题
Yac
目录
- 简介
- 安装/配置
- 预定义常量
- Yac — The Yac class
- Yac::add — Store into cache
- Yac::__construct — Constructor
- Yac::delete — Remove items from cache
- Yac::dump — Dump cache
- Yac::flush — Flush the cache
- Yac::get — Retrieve values from cache
- Yac::__get — Getter
- Yac::info — Status of cache
- Yac::set — Store into cache
- Yac::__set — Setter
简介
类摘要
Yac
class Yac {
/* 属性 */
protected $_prefix ;
/* 方法 */
public <span
class="methodname">__construct ([ <span
class="methodparam">string $prefix<span
class="initializer"> = "" ] )
public bool
add ( <span
class="type">string $keys , <span
class="methodparam">mixed $value [,
int $ttl<span
class="initializer"> = 0 ] )
public bool
add ( <span
class="type">array $key_vals )
public bool
delete ( <span
class="type">string<span
class="type">array $keys [, <span
class="methodparam">int $ttl ] )
public mixed
dump ( <span
class="type">int $$num )
public bool flush ( <span class="methodparam">void )
public mixed
get ( <span
class="type">string<span
class="type">array $key [, <span
class="methodparam">int &$cas<span
class="initializer"> = null ] )
public mixed
__get ( <span
class="methodparam">string $key )
public array info ( <span class="methodparam">void )
public bool
set ( <span
class="type">string $keys , <span
class="methodparam">mixed $value [,
int $ttl<span
class="initializer"> = 0 ] )
public bool
add ( <span
class="type">array $key_vals )
public mixed
__set ( <span
class="methodparam">string $keys ,
mixed
$value )
}
属性
_prefix
Yac::add
Store into cache
说明
public bool
Yac::add ( <span
class="methodparam">string $keys ,
mixed
$value [, <span
class="type">int $ttl =
0 ] )
public bool
Yac::add ( <span
class="methodparam">array $key_vals )
Added a item into cache.
参数
keys
string key
value
mixed value, All php value type could be stored except
资源(resource)
ttl
expire time
返回值
bool, true on success, false on
failure
Note:
Yac::add may fail if cas lock could not obtain, so, if you need the value to be stored properly, you may write codes like:
示例 #1 Make sure the item is stored
while(!$yac->set("key", "vale));
Yac::__construct
Constructor
说明
public <span
class="methodname">Yac::__construct ([ <span
class="methodparam">string $prefix<span
class="initializer"> = "" ] )
prefix is used to prepended to keys, this could be used to avoiding conflicts between apps.
参数
prefix
string prefix
Yac::delete
Remove items from cache
说明
public bool
Yac::delete ( <span
class="methodparam"><span
class="type">stringarray
$keys [, <span
class="type">int $ttl ] )
remove items from cache
参数
keys
string key, or array of multiple keys to be removed
ttl
if delay is set, delete will mark the items to be invalid in ttl second.
返回值
Yac::dump
Dump cache
说明
public mixed
Yac::dump ( <span
class="methodparam">int $$num )
Dump values stored in cache
参数
num
Maximum number of items should be returned
返回值
mixed
Yac::flush
Flush the cache
说明
public bool Yac::flush ( <span class="methodparam">void )
Remove all cached values
参数
此函数没有参数。
返回值
bool, always true
Yac::get
Retrieve values from cache
说明
public mixed
Yac::get ( <span
class="methodparam"><span
class="type">stringarray
$key [, <span
class="type">int &$cas =
null ] )
Retrieve values from cache
参数
key
string keys, or <span
class="type">array of multiple keys.
cas
if not null, it will be set to the retrieved item's cas.
返回值
mixed on success, false on failure
Yac::__get
Getter
说明
public mixed
Yac::__get ( <span
class="methodparam">string $key )
Retrieve values from cache
参数
key
string key
返回值
mixed on success, null on failure
Yac::info
Status of cache
说明
public array Yac::info ( <span class="methodparam">void )
Get status of cache system
参数
此函数没有参数。
返回值
Return an array, consistent with: "memory_size", "slots_memory_size", "values_memory_size", "segment_size", "segment_num", "miss", "hits", "fails", "kicks", "recycles", "slots_size", "slots_used"
Yac::set
Store into cache
说明
public bool
Yac::set ( <span
class="methodparam">string $keys ,
mixed
$value [, <span
class="type">int $ttl =
0 ] )
public bool
Yac::add ( <span
class="methodparam">array $key_vals )
Add a item into cache, it the key is already exists, override it.
参数
keys
string key
value
mixed value, All php value type could be stored except
资源(resource)
ttl
expire time
返回值
the value self
Yac::__set
Setter
说明
public mixed
Yac::__set ( <span
class="methodparam">string $keys ,
mixed
$value )
store a item into cache
参数
keys
string key
value
mixed value, All php value type could be stored except
资源(resource)
返回值
Always return the value self