ThinkPHP5


think\cache\driver\Redis
library\think\cache\driver\Redis.php at line 23

Class Redis

Driver
└─Redis

public class Redis
extends Driver

Redis缓存驱动,适合单机部署、有前端代理实现高可用的场景,性能最好 有需要在业务层实现读写分离、或者使用RedisCluster的需求,请使用Redisd驱动

要求安装phpredis扩展:https://github.com/nicolasff/phpredis

Author:
尘缘 <130775@qq.com>

Constructor Summary
void

__construct(array options)

架构函数

Method Summary
bool

has(string name)

判断缓存

mixed

get(string name, mixed default)

读取缓存

boolean

set(string name, mixed value, integer expire)

写入缓存

false|int

inc(string name, int step)

自增缓存(针对数值缓存)

false|int

dec(string name, int step)

自减缓存(针对数值缓存)

boolean

rm(string name)

删除缓存

boolean

clear(string tag)

清除缓存

Methods inherited from think\cache\Driver
clear, dec, get, getCacheKey, getTagItem, handler, has, inc, pull, rm, set, setTagItem, tag

Constructor Detail

library\think\cache\driver\Redis.php at line 32

__construct

public void __construct(array options)

架构函数

Parameters:
options - 缓存参数

Method Detail

library\think\cache\driver\Redis.php at line 59

has

public bool has(string name)

判断缓存

Parameters:
name - 缓存变量名

library\think\cache\driver\Redis.php at line 71

get

public mixed get(string name, mixed default)

读取缓存

Parameters:
name - 缓存变量名
default - 默认值

library\think\cache\driver\Redis.php at line 90

set

public boolean set(string name, mixed value, integer expire)

写入缓存

Parameters:
name - 缓存变量名
value - 存储数据
expire - 有效时间(秒)

library\think\cache\driver\Redis.php at line 117

inc

public false|int inc(string name, int step)

自增缓存(针对数值缓存)

Parameters:
name - 缓存变量名
step - 步长

library\think\cache\driver\Redis.php at line 130

dec

public false|int dec(string name, int step)

自减缓存(针对数值缓存)

Parameters:
name - 缓存变量名
step - 步长

library\think\cache\driver\Redis.php at line 142

rm

public boolean rm(string name)

删除缓存

Parameters:
name - 缓存变量名

library\think\cache\driver\Redis.php at line 153

clear

public boolean clear(string tag)

清除缓存

Parameters:
tag - 标签名

ThinkPHP5