Cache items in pool
Seeren\Cache is a PSR-6 cache interfaces implementation
composer require seeren/cacheStore item in stream pool
use Seeren\Cache\Pool\StreamCacheItemPool;
$pool = new StreamCacheItemPool();
$item = $pool
->getItem('foo')
->expiresAfter(5);
if (!$item->isHit()) {
$item->set("item data");
$pool->save();
}
$data = $item->get();By default, cache folder is in /var/cache
project/
└─ var/
└─ log/Use item for manage Last-Modified with the extra method last
$response = $response
->withHeader("ETag", $eTag)
->withHeader("Last-Modified", $item->last())
->withHeader("Cache-Control", "public, max-age=" . $timeToLive)
->withHeader("Expires", $item->last(true));Passing true at
lastadd the timeToLive to the lastSave timestamp
This project is licensed under the MIT License