ThinkPHP5


think\Cache
library\think\Cache.php at line 16

Class Cache

Cache

public class Cache


Field Summary
static mixed

$readTimes

static mixed

$writeTimes

Method Summary
static \think\cache\Driver

connect(array options, bool|string name)

连接缓存

static void

init(array options)

自动初始化缓存

static \think\cache\Driver

store(string name)

切换缓存类型 需要配置 cache.type 为 complex

static bool

has(string name)

判断缓存是否存在

static mixed

get(string name, mixed default)

读取缓存

static boolean

set(string name, mixed value, int|null expire)

写入缓存

static false|int

inc(string name, int step)

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

static false|int

dec(string name, int step)

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

static boolean

rm(string name)

删除缓存

static boolean

clear(string tag)

清除缓存

static \think\cache\Driver

tag(string name, string|array keys, bool overlay)

缓存标签

Field Detail

library\think\Cache.php at line 19

readTimes

public static mixed $readTimes = 0

library\think\Cache.php at line 20

writeTimes

public static mixed $writeTimes = 0

Method Detail

library\think\Cache.php at line 36

connect

public static \think\cache\Driver connect(array options, bool|string name)

连接缓存

Parameters:
options - 配置数组
name - 缓存连接标识 true 强制重新连接

library\think\Cache.php at line 64

init

public static void init(array options)

自动初始化缓存

Parameters:
options - 配置数组

library\think\Cache.php at line 84

store

public static \think\cache\Driver store(string name)

切换缓存类型 需要配置 cache.type 为 complex

Parameters:
name - 缓存标识

library\think\Cache.php at line 98

has

public static bool has(string name)

判断缓存是否存在

Parameters:
name - 缓存变量名

library\think\Cache.php at line 112

get

public static mixed get(string name, mixed default)

读取缓存

Parameters:
name - 缓存标识
default - 默认值

library\think\Cache.php at line 127

set

public static boolean set(string name, mixed value, int|null expire)

写入缓存

Parameters:
name - 缓存标识
value - 存储数据
expire - 有效时间 0为永久

library\think\Cache.php at line 141

inc

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

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

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

library\think\Cache.php at line 155

dec

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

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

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

library\think\Cache.php at line 168

rm

public static boolean rm(string name)

删除缓存

Parameters:
name - 缓存标识

library\think\Cache.php at line 181

clear

public static boolean clear(string tag)

清除缓存

Parameters:
tag - 标签名

library\think\Cache.php at line 196

tag

public static \think\cache\Driver tag(string name, string|array keys, bool overlay)

缓存标签

Parameters:
name - 标签名
keys - 缓存标识
overlay - 是否覆盖

ThinkPHP5