vakata / cache
A collection of caching classes with a common interface
Installs: 4 174
Dependents: 2
Suggesters: 1
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- psr/simple-cache: ~1.0
README
A collection of caching classes with a common interface (currently file cache and memcached are supported).
Install
Via Composer
$ composer require vakata/cache
Usage
// create an instance (with file based cache) // caches will be stored in the dir specified by the first argument $cache = new \vakata\cache\Filecache(__DIR__ . '/cache'); // to use Memcached instead simply create a memcached instance: // $cache = new \vakata\cache\Memcache(); // by default connects to 127.0.0.1 // simple get / set $cache->set('key', 'value'); // key is stored and "value" is returned $cache->get('key'); // "value" // using prepare ensures that a single client updates the cache at any given moment $cache->prepare('long-running-operation'); $data = long_running_operation(); $cache->set('long-running-operation', $data); // there is a special getSet method which gets the current key value and if it does not exist - invokes a callable, stores the result and returns it: $cache->getSet('some-key', function () { return some_long_running_operation(); });
Read more in the API docs
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.