battis/simplecache

This package is abandoned and no longer maintained. No replacement package was suggested.

Manage a simple cache backed by a MySQL database

v1.2.2 2015-12-17 02:04 UTC

This package is auto-updated.

Last update: 2023-05-25 12:40:55 UTC


README

Latest Version Scrutinizer Code Quality Code Coverage Build Status

Manage a simple cache backed by a MySQL database

Install

In your composer.json add:

"require": {
  "battis/simplecache": "1.*"
}

Use

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.