A collection of caching classes with a common interface

3.0.2 2024-03-26 15:23 UTC

This package is auto-updated.

Last update: 2024-04-26 15:26:34 UTC


Latest Version on Packagist Software License Build Status Code Climate Tests Coverage

A collection of caching classes with a common interface (currently file cache and memcached are supported).


Via Composer

$ composer require vakata/cache


// 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

// 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
$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


$ composer test


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.