phore/cache

v1.0 2019-12-02 17:27 UTC

This package is auto-updated.

Last update: 2024-09-10 18:59:18 UTC


README

安装

composer require phore/cache

基本用法

设置驱动程序

$pool = new CacheItemPool(new RedisCacheDriver("redis://redis"));

或快捷方式

$pool = new CacheItemPool("redis://redis");

加载和缓存数据

$pool = new CacheItemPool("redis://redis");
$item = $pool->getItem("cachekey")->expiresAfter(10)->retryAfter(5);
echo $item->load(function () {
    return "Data"; // Put code to load the cached value
});

文件系统驱动程序

$pool = new CacheItemPool("file:///tmp");