PHP Simple Cache
PHP class to cache dynamic pages in file and reduce Database overload, (*1)
Install
Install via composer:, (*2)
{
"require": {
"rodrigoalviani/php-simple-cache": "~0.1"
}
}
Run composer install
then use as normal:, (*3)
require 'vendor/autoload.php';
$cache = new Rodrigoalviani\Cache\Cache($label);
Usage
A very basic usage example:, (*4)
$cache = new Rodrigoalviani\Cache\Cache($_SERVER['REQUEST_URI']);
$cache->cacheInit();
// your page here
$cache->cacheEnd();
A more advanced example:, (*5)
$cache = new Rodrigoalviani\Cache\Cache($_SERVER['REQUEST_URI']);
$cache->set_filePath('tmp/');
$cache->set_cacheMaxAge(84600);
$cache->set_cacheExtension('.tmp');
$cache->cacheInit();
// your page here
$cache->cacheEnd();
Credits
PHP Simple Cache was created by Rodrigo Alviani. Released under the MIT license., (*6)