SimpleCache
, (*1)
Manage a simple cache backed by a MySQL database, (*2)
Install
In your composer.json
add:, (*3)
"require": {
"battis/simplecache": "1.*"
}
Use
Create a cache:, (*4)
$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):, (*5)
$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., (*6)