https://github.com/caferrari/cache
Simple caching library
https://github.com/caferrari/cache
Last synced: over 1 year ago
JSON representation
Simple caching library
- Host: GitHub
- URL: https://github.com/caferrari/cache
- Owner: caferrari
- Created: 2014-08-08T23:32:58.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-08-29T18:26:35.000Z (almost 12 years ago)
- Last Synced: 2025-02-08T08:47:37.436Z (over 1 year ago)
- Language: PHP
- Size: 160 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# caferrari\Cache
[](http://travis-ci.org/caferrari/Cache)
[](https://coveralls.io/r/caferrari/Cache?branch=master)
[](https://packagist.org/packages/ferrari/cache)
[](https://packagist.org/packages/ferrari/cache)
[](https://packagist.org/packages/ferrari/cache)
[](https://packagist.org/packages/ferrari/cache)
## Installation
Package is available on [Packagist](https://packagist.org/packages/ferrari/cache), you can install it
using [Composer](http://getcomposer.org).
```bash
composer require ferrari/cache
```
## Usage
```php
$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
```