borschphp / cache
A simple PSR-6 and PSR-16 implementation.
1.0.0
2024-05-12 12:31 UTC
Requires
- php: ^8.1
- psr/cache: ^3.0
- psr/log: ^3.0
- psr/simple-cache: ^3.0
Requires (Dev)
- pestphp/pest: ^2.34
This package is auto-updated.
Last update: 2024-11-12 13:27:05 UTC
README
A simple PSR-6 and PSR-16 implementation.
Installation
Via composer :
composer require borschphp/cache
Usage
// PSR-16 style $cache = new Cache(new InMemoryCacheItemPool()); $cache->set('foo', 'bar'); $foo = $cahce->get('foo', 'default_value'); $cahce->delete('foo'); $cache->clear(); // PSR-6 style $pool = new InMemoryCacheItemPool(); $pool->save(new CacheItem('foo', 'bar')); if ($pool->hasItem('foo')) { $foo = $pool->getItem('foo')->get(); $pool->deleteItem('foo'); } $pool->clear();
A LoggerInterface
instance can be given as a second parameter to the Cache
class to log errors during cache operations.
License
The package is licensed under the MIT license.
See License File for more information.