Home

Awesome

caferrari\Cache

Build Status Coverage Status Total Downloads License Latest Stable Version Latest Unstable Version

Installation

Package is available on Packagist, you can install it using Composer.

composer require ferrari/cache

Usage


$driver = new \Doctrine\Common\Cache\ArrayCache;

$cache = new \Ferrari\Cache($driver);

$cache->save('hello', 'world');

echo $cache->fetch('hello'); // 'world'
echo $cache['hello']; // 'world'

$cache->delete('hello'); // true

$cache->get('foo', function() {
    return 'bar';
}); // 'bar'

echo $cache['foo']; // 'bar'

$cache['foo'] = 'walla!';

$cache->get('foo', function () {
    'tchubiru'
}); // 'walla!'

unset($cache['foo']);

echo $cache->fetch('foo'); // false