PHP 클래스 Cml\Cache\Redis

상속: extends Base
파일 보기 프로젝트 열기: linhecheng/cmlphp 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( $conf = false ) 使用的缓存配置 默认为使用default_cache配置的参数
__construct ( bool|array $conf = false ) 使用的缓存配置 默认为使用default_cache配置的参数
__destruct ( ) 定义析构方法。不用判断长短连接,长链接执行close无效
decrement ( mixed $key, integer $val = 1 ) : boolean 自减
delete ( mixed $key ) : boolean 删除对象
exists ( mixed $key ) : mixed 判断key值是否存在
get ( mixed $key ) : boolean | array 根据key取值
getInstance ( string $key = '' ) : Redis 返回实例便于操作未封装的方法
increment ( mixed $key, integer $val = 1 ) : boolean 自增
set ( mixed $key, mixed $value, integer $expire ) : boolean 存储对象
truncate ( ) 清洗已经存储的所有元素
update ( mixed $key, mixed $value, integer $expire ) : boolean | integer 更新对象

비공개 메소드들

메소드 설명
hash ( $key ) : Redis 根据key获取redis实例 这边还是用取模的方式,一致性hash用php实现性能开销过大。取模的方式对只有几台机器的情况足够用了 如果有集群需要,直接使用redis3.0+自带的集群功能就好了。不管是可用性还是性能都比用php自己实现好

메소드 상세

__construct() 공개 메소드

使用的缓存配置 默认为使用default_cache配置的参数
public __construct ( $conf = false )

__construct() 공개 메소드

使用的缓存配置 默认为使用default_cache配置的参数
public __construct ( bool|array $conf = false )
$conf bool|array

__destruct() 공개 메소드

定义析构方法。不用判断长短连接,长链接执行close无效
public __destruct ( )

decrement() 공개 메소드

自减
public decrement ( mixed $key, integer $val = 1 ) : boolean
$key mixed 要自减的缓存的数据的key
$val integer 自减的进步值,默认为1
리턴 boolean

delete() 공개 메소드

删除对象
public delete ( mixed $key ) : boolean
$key mixed 要删除的数据的key
리턴 boolean

exists() 공개 메소드

判断key值是否存在
public exists ( mixed $key ) : mixed
$key mixed 要判断的缓存的数据的key
리턴 mixed

get() 공개 메소드

根据key取值
public get ( mixed $key ) : boolean | array
$key mixed 要获取的缓存key
리턴 boolean | array | array

getInstance() 공개 메소드

返回实例便于操作未封装的方法
public getInstance ( string $key = '' ) : Redis
$key string
리턴 Redis

increment() 공개 메소드

自增
public increment ( mixed $key, integer $val = 1 ) : boolean
$key mixed 要自增的缓存的数据的key
$val integer 自增的进步值,默认为1
리턴 boolean

set() 공개 메소드

存储对象
public set ( mixed $key, mixed $value, integer $expire ) : boolean
$key mixed 要缓存的数据的key
$value mixed 要缓存的值,除resource类型外的数据类型
$expire integer 缓存的有效时间 0为不过期
리턴 boolean

truncate() 공개 메소드

清洗已经存储的所有元素
public truncate ( )

update() 공개 메소드

更新对象
public update ( mixed $key, mixed $value, integer $expire ) : boolean | integer
$key mixed 要更新的数据的key
$value mixed 要更新缓存的值,除resource类型外的数据类型
$expire integer 缓存的有效时间 0为不过期
리턴 boolean | integer