phore / cache
Caching library
Installs: 1 689
Dependents: 3
Suggesters: 2
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- phore/core: *
- psr/cache: ^1.0@dev
Requires (Dev)
Suggests
- phore/objectstore: Use object-store
This package is auto-updated.
Last update: 2024-12-10 19:35:17 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");