缓存池

遵循 PSR6 规范,使用静态方法调用
属性
命名空间 fize\cache
类名 Pool
方法:
方法名 说明
__construct() 常规调用请先初始化
getInstance() 取得实例
getItem() 获取缓存项
getItems() 返回一个可供遍历的缓存项集合
hasItem() 检查是否有对应的缓存项
clear() 清空缓存池
deleteItem() 从缓存池里移除缓存项
deleteItems() 移除多个缓存项
save() 立刻为对象做数据持久化
saveDeferred() 稍后为缓存项做数据持久化
commit() 提交所有的正在队列里等待的请求到数据持久层
saveItems() 设置多个缓存项

方法

__construct()

常规调用请先初始化

public function __construct (
    string $handler,
    array $config = []
)
参数:
名称 说明
handler 使用的实际接口名称
config 配置项

getInstance()

取得实例

public static function getInstance (
    string $handler,
    array $config = []
) : \fize\cache\PoolInterface
参数:
名称 说明
handler 使用的实际接口名称
config 配置

getItem()

获取缓存项

public static function getItem (
    string $key
) : \Psr\Cache\CacheItemInterface
参数:
名称 说明
key 键名

getItems()

返回一个可供遍历的缓存项集合

public static function getItems (
    array $keys = []
) : \CacheItemInterface[]
参数:
名称 说明
keys 键名组成的数组

hasItem()

检查是否有对应的缓存项

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

clear()

清空缓存池

public static function clear () : bool

deleteItem()

从缓存池里移除缓存项

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

deleteItems()

移除多个缓存项

public static function deleteItems (
    array $keys
) : bool
参数:
名称 说明
keys 键名组成的数组

save()

立刻为对象做数据持久化

public static function save (
    \Psr\Cache\CacheItemInterface $item
) : bool
参数:
名称 说明
item 缓存对象

saveDeferred()

稍后为缓存项做数据持久化

public static function saveDeferred (
    \Psr\Cache\CacheItemInterface $item
) : bool
参数:
名称 说明
item  

commit()

提交所有的正在队列里等待的请求到数据持久层

public static function commit () : bool

saveItems()

设置多个缓存项

public static function saveItems (
    \CacheItemInterface[] $items
) : bool
参数:
名称 说明
items