Skip to content

borschphp/borsch-cache

Repository files navigation

Borsch Cache

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.

About

A simple PSR-6 and PSR-16 implementation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages