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