PHP code example of trafficinc / php-easycache
1. Go to this page and download the library: Download trafficinc/php-easycache 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/ */
trafficinc / php-easycache example snippets
$cache = new Trafficinc\Util\EasyCache();
$cache = new Trafficinc\Util\EasyCache();
$cache->cache_path = 'cache/';
$cache->cache_time = 3600;
if($data = $cache->get_cache('label')){
$data = json_decode($data);
} else {
$data = $cache->do_request('https://jsonplaceholder.typicode.com/posts/1');
$cache->set_cache('label', $data);
$data = json_decode($data);
}
print_r($data);
// clear single cache file by id
$cache->clear('label');
// clear whole cache
$cache->clear();