seeren / cache
Manage pool cache items
Installs: 136
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/seeren/cache
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