composer require hyqo/cache
use Hyqo\Cache\Layer\FilesystemLayer;
use Hyqo\Cache\CacheItem
$cache = new FilesystemLayer('namespace', /*lifetime*/0, 'cache_dir');
$item = $cache->getItem('key', function () {
return 'ageless cache';
});
$item = $cache->getItem('key', function (\Hyqo\Cache\CacheItem $cacheItem) {
$cacheItem->setExpiresAfter(60);
return 'value will be expired after 60 seconds';
});
//expected cache key creation unix time
$item = $cache->getItemCreatedAfter(12345678, 'key', function (\Hyqo\Cache\CacheItem $cacheItem) {
$cacheItem->setExpiresAfter(60);
return 'value will be expired after 60 seconds';
});
$value = $item->get();