https://github.com/seeren/cache
🥡 Cache items in pool
https://github.com/seeren/cache
cache items pool psr-6
Last synced: 3 months ago
JSON representation
🥡 Cache items in pool
- Host: GitHub
- URL: https://github.com/seeren/cache
- Owner: seeren
- License: mit
- Created: 2016-10-29T00:50:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-01-07T22:29:09.000Z (over 3 years ago)
- Last Synced: 2024-12-02T13:19:02.998Z (6 months ago)
- Topics: cache, items, pool, psr-6
- Language: PHP
- Homepage:
- Size: 88.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Seeren\\Cache
[](https://app.travis-ci.com/seeren/cache)
[](https://packagist.org/packages/seeren/cache)
[](https://coveralls.io/github/seeren/cache?branch=master)
[](https://packagist.org/packages/seeren/cache/stats)
[](https://www.codacy.com/gh/seeren/cache/dashboard?utm_source=github.com&utm_medium=referral&utm_content=seeren/cache&utm_campaign=Badge_Grade)
[](https://packagist.org/packages/seeren/cache)Cache items in pool
## Installation
Seeren\\Cache is a [PSR-6 cache interfaces](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-6-cache.md) implementation
```bash
composer require seeren/cache
```* * *
## Seeren\\Cache\\StreamCacheItemPool
Store item in stream pool
```php
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
```bash
project/
└─ var/
└─ log/
```* * *
## Seeren\\Cache\\CacheItem
Use item for manage `Last-Modified` with the extra method `last`
```php
$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) License