phore/cache

Caching library

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

This package is auto-updated.

Last update: 2024-10-10 19:05:52 UTC


README

Installation

composer require phore/cache

Basic usage

Setting a driver:

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

or shortcut:

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

Load and cache data

$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
});

Filesystem driver

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