Yac

目录

简介

类摘要

Yac

class Yac {

/* 属性 */

protected $_prefix ;

/* 方法 */

public __construct ([ string $prefix = "" ] )

public bool add ( string $keys , mixed $value [, int $ttl = 0 ] )

public bool add ( array $key_vals )

public bool delete ( string|array $keys [, int $ttl ] )

public mixed dump ( int $$num )

public bool flush ( void )

public mixed get ( string|array $key [, int &$cas = NULL ] )

public mixed __get ( string $key )

public array info ( void )

public bool set ( string $keys , mixed $value [, int $ttl = 0 ] )

public bool add ( array $key_vals )

public mixed __set ( string $keys , mixed $value )

}

属性

_prefix

Yac::add

Store into cache

说明

public bool Yac::add ( string $keys , mixed $value [, int $ttl = 0 ] )

public bool Yac::add ( 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

返回值

boolean, 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 Yac::__construct ([ string $prefix = "" ] )

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 ( string|array $keys [, 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 ( 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 ( void )

Remove all cached values

参数

此函数没有参数。

返回值

bool, always true

Yac::get

Retrieve values from cache

说明

public mixed Yac::get ( string|array $key [, int &$cas = NULL ] )

Retrieve values from cache

参数

key
string keys, or 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 ( string $key )

Retrieve values from cache

参数

key
string key

返回值

mixed on success, NULL on failure

Yac::info

Status of cache

说明

public array Yac::info ( 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 ( string $keys , mixed $value [, int $ttl = 0 ] )

public bool Yac::add ( 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 ( 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