1. Go to this page and download the library: Download mlevent/file-cache 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/ */
mlevent / file-cache example snippets
use Mlevent\FileCache\FileCache;
$cache = new FileCache;
$updatedTime = $cache->refresh('updatedTime', function () {
return date("H:i:s");
}, 60);
echo "Updated time: {$updatedTime}";
use Mlevent\FileCache\FileCache;
// Önbellek dosyaları ./cache dizininde saklanacak
$cache = new FileCache('./cache');
// Geçerlilik süresi dolduysa
if ($cache->isExpired('updatedTime')) {
// Geçerlilik süresini 60 saniye daha uzat ve yeni veriyi yaz
$cache->put('updatedTime', date("H:i:s"), 60);
}
// Veriyi önbellekten oku
$updatedTime = $cache->get('updatedTime');
echo "Updated time: {$updatedTime}";