数据库形式缓存类

属性
命名空间 fize\cache\handler
类名 Database
实现接口 fize\cache\CacheHandler
方法:
方法名 说明
__construct() 构造函数
get() 获取一个缓存
has() 查看指定缓存是否存在
set() 设置一个缓存
remove() 删除一个缓存
clear() 清空缓存
initMysql() 初始化,如果尚未建立 cache 表,可以运行该方法来建立表

方法

__construct()

构造函数

public function __construct (

    array $config = []

)
参数:
名称 说明
config 初始化默认选项

get()

获取一个缓存

public function get (

    string $name,

    mixed $default = null

) : mixed
参数:
名称 说明
name 缓存名
default 默认值

has()

查看指定缓存是否存在

public function has (

    string $name

) : bool
参数:
名称 说明
name 缓存名

set()

设置一个缓存

public function set (

    string $name,

    mixed $value,

    int $expire = null

)
参数:
名称 说明
name 缓存名
value 缓存值
expire 有效时间,以秒为单位,0表示永久有效。
参数 `$expire` :
不设置则使用当前配置

remove()

删除一个缓存

public function remove (

    string $name

)
参数:
名称 说明
name 缓存名

clear()

清空缓存

public function clear ()

initMysql()

初始化,如果尚未建立 cache 表,可以运行该方法来建立表

public static function initMysql (

    array $config

)
参数:
名称 说明
config  
适用于mysql