borschphp / cache
A simple PSR-6 and PSR-16 implementation.
2.0.0
2025-05-06 09:57 UTC
Requires
- php: ^8.2
- doctrine/collections: ^2.3
- psr/cache: ^3.0
- psr/log: ^3.0
- psr/simple-cache: ^3.0
Requires (Dev)
- pestphp/pest: ^3.8
- phpstan/phpstan: ^2.1
This package is auto-updated.
Last update: 2025-05-06 10:04:43 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 ArrayCacheItemPool()); $cache->set('foo', 'bar'); $foo = $cache->get('foo', 'default_value'); $cache->delete('foo'); $cache->clear(); // PSR-6 style $pool = new ArrayCacheItemPool(); $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.