seeren / cache
Manage pool cache items
2.0
2022-01-07 22:28 UTC
Requires
- php: >=8.0.1
- psr/cache: ^3.0
- seeren/http: ^4.0
Requires (Dev)
- php-coveralls/php-coveralls: ^v2.5.2
- phpunit/phpunit: ^9.5
README
Cache items in pool
Installation
Seeren\Cache is a PSR-6 cache interfaces implementation
composer require seeren/cache
Seeren\Cache\StreamCacheItemPool
Store 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/
Seeren\Cache\CacheItem
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
last
add the timeToLive to the lastSave timestamp
License
This project is licensed under the MIT License