Manage a simple cache backed by a MySQL database
In your composer.json
add:
"require": {
"battis/simplecache": "1.*"
}
Create a cache:
$mysqli = new mysqli('localhost', 'bob', 's00pers3kr3t', 'app-db'); // or whatever your credentials are
$cache = new \Battis\SimpleCache($mysqli);
Basic workflow using cached data (check the cache and used cached data if there, otherwise build data and cache it for next time):
$data = $cache->getCache('foo');
if ($data === false) {
// ... lots and lots of work to create $data from scratch
$cache->setCache('foo', $data); // cache for next use
}
Full API documentation is available in /docs.