Drivers
The Filecache Driver
Introduction
The File driver provides a simple and efficient way to store and retrieve data on disk.
Except for very rare cases, it is not recommended for production use.
It is based on the excellent Symfony Cache component and provides a convenient interface.
Installation
Install the driver via composer by running:
composer require kipchak/driver-filecache
Initialise the Driver
Add the following line to your drivers/drivers.php file:
\Mamluk\Kipchak\Driver\Filecache\Filecache::iniitalise($container);
Configuration
This driver has no configuration.
Usage
use Kipchak\Driver\Filecache\Filecache;
use Symfony\Contracts\Cache\ItemInterface;
$cache = Filecache::get();
$value = $cache->get('my_cache_key', function (ItemInterface $item) {
$item->expiresAfter(3600); // Cache for 1 hour
// Expensive operation here
return 'cached value';
});
Git Repository
The source code for this driver is available on 1x.ax at https://1x.ax/mamluk/kipchak/drivers/filecache.