简易缓存

属性
命名空间 fize\cache\handler\redis
类名 Cache
父类 fize\cache\AbstractCache
实现接口 Psr\SimpleCache\CacheInterface, fize\cache\CacheInterface
方法:
方法名 说明
__construct() 构造函数
get() 获取一个缓存
set() 设置一个缓存
delete() 删除一个缓存
clear() 清除所有缓存
getMultiple() 获取多个缓存
setMultiple() 设置多个缓存
deleteMultiple() 删除多个缓存
has() 判断缓存是否存在

方法

__construct()

构造函数

public function __construct (
    array $config = []
)
参数:
名称 说明
config 配置

get()

获取一个缓存

public function get (
    string $key,
    mixed $default = null
) : mixed
参数:
名称 说明
key 键名
default 默认值

set()

设置一个缓存

public function set (
    string $key,
    mixed $value,
    \DateInterval|int|null $ttl = null
) : bool
参数:
名称 说明
key 键名
value
ttl 以秒为单位的过期时长

delete()

删除一个缓存

public function delete (
    string $key
) : bool
参数:
名称 说明
key 键名

clear()

清除所有缓存

public function clear () : bool

getMultiple()

获取多个缓存

public function getMultiple (
    iterable $keys,
    mixed $default = null
) : iterable
参数:
名称 说明
keys 键名数组
default 默认值

setMultiple()

设置多个缓存

public function setMultiple (
    iterable $values,
    \DateInterval|int|null $ttl = null
) : bool
参数:
名称 说明
values [键名=>值]数组
ttl 以秒为单位的过期时长

deleteMultiple()

删除多个缓存

public function deleteMultiple (
    iterable $keys
) : bool
参数:
名称 说明
keys 键名数组

has()

判断缓存是否存在

public function has (
    string $key
) : bool
参数:
名称 说明
key 键名