phore/cache

Caching library

dev-master 2019-12-02 17:27 UTC

This package is auto-updated.

Last update: 2020-03-31 18:12:45 UTC


README

Installation

composer require phore/cache

Basic usage

Setting a driver:

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

or shortcut:

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

Load and cache data

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