1. Go to this page and download the library: Download rothkj1022/php-cache-class library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rothkj1022 / php-cache-class example snippets
//load composer packages
f the class
use rothkj1022\FileCache;
$cache = new FileCache\FileCache("tmp/");
//equire_once("lib/FileCache.php");
//create new instance of the class
use rothkj1022\FileCache;
$cache = new FileCache\FileCache("tmp/");
//...
$cache_key = "client_list";
//see if we can get an existing cache
if (!$clients_data = $cache->get($cache_key)) {
//nope. Let's get the real one!
$clients_data = json_decode(file_get_contents("clients.json"));
//set the cache up!
$expire = 3600; //1 hour
$cache->set($cache_key, $clients_data, $expire);
}
var_dump($clients_data);