A simple PSR-6 and PSR-16 implementation.
Via composer :
composer require borschphp/cache
// 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.
The package is licensed under the MIT license.
See License File for more information.