A PSR-16 implementation for very simple caching. Nothing fancy. Just dead-simple caching.

0.3.1 2021-09-24 13:42 UTC

This package is auto-updated.

Last update: 2021-09-24 13:43:33 UTC


This is a simple, flexible PSR-16 compliant simple-cache implementation for PHP.

Adapters include File, Sql, and Memcached

Documentation is coming, but for now:


include 'vendor/autoload.php';

use \Vespula\Cache\Adapter\Memcached as MemcachedCache;
use \Vespula\Cache\Adapter\File as FileCache;
use \Vespula\Cache\Adapter\Sql as SqlCache;

$phpmemcached = new \Memcached();
$phpmemcached->addServer('localhost', 11211);

// Expire in 3600 seconds (1 hr)
// Setting the expiry to 0 indicates NO expiry.
$adapter = new MemcachedCache($phpmemcached, 3600);

$data = [
    'foo'=>'this is foo',
    'bar'=>'this is bar',



// Set a value in the cache with expiry of 1800s (30 min)
$adapter->set('cat', 'meow', 1800);

// Get a value. If it doesn't exist, return a default value
$value = $adapter->get('cat', 'a default value');

// Delete a value

// Check for presence in the cache
$is_cached = $adapter->has($key);

// Delete all entries in the cache

// Update the expiry on an item
$adapter->touch($key, $ttl);

// Delete multiples
$keys = [



$path = '/some/path/cache'; // read and write by web server process
$fileAdapter = new FileCache($path, 3600);

$pdo = new \PDO("mysql:host=localhost;dbname=mydb;charset=utf8", 'username', '******');
$table = 'vespula_cache';
$sqlAdapter = new SqlCache($pdo, 3600, $table);

Basic interface for PSR-16 is here: