SQL Adapter

Use a database table for your cache. I don’t imagine this would be very efficient.

<?php
include 'vendor/autoload.php';

use \Vespula\Cache\Adapter\Sql as SqlCache;

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

/ Set a value by key with key-specific ttl (optional)
$adapter->set('cat', 'meow', 1800);

// returns 'meow' if still in cache
$value = $adapter->get('cat');

// returns 'meow' if still in cache, or 'some default' if not.
$value = $adapter->get('cat', 'some default');

// Delete a value by key
$adapter->delete('cat');

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

// Delete all entries in the cache
$adapter->flush();

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

// Delete multiples
$keys = [
    'foo',
    'bar'
];

$adapter->deleteMultiple($keys);