File Adapter

The file adapter stores cached values on the filesystem in a writeable folder.

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

use \Vespula\Cache\Adapter\File as FileCache;

$path = '/some/path/cache'; // read and write by web server, or PHP process
$default_ttl = 3600; // 3600 seconds
$adapter = new FileCache($path, $default_ttl);

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