数据库形式缓存类¶
| 属性 | 值 |
|---|---|
| 命名空间 | fize\cache\handler |
| 类名 | Database |
| 实现接口 | fize\cache\CacheHandler |
| 方法: |
|---|
| 方法名 | 说明 |
|---|---|
| __construct() | 构造函数 |
| get() | 获取一个缓存 |
| has() | 查看指定缓存是否存在 |
| set() | 设置一个缓存 |
| remove() | 删除一个缓存 |
| clear() | 清空缓存 |
| initMysql() | 初始化,如果尚未建立 cache 表,可以运行该方法来建立表 |
方法¶
get()¶
获取一个缓存
public function get (
string $name,
mixed $default = null
) : mixed
| 参数: |
|
|---|
set()¶
设置一个缓存
public function set (
string $name,
mixed $value,
int $expire = null
)
| 参数: |
|
|---|
参数 `$expire` :
不设置则使用当前配置
initMysql()¶
初始化,如果尚未建立 cache 表,可以运行该方法来建立表
public static function initMysql (
array $config
)
| 参数: |
|
|---|
适用于mysql