PHP code example of em4nl / ucache
1. Go to this page and download the library: Download em4nl/ucache 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/ */
em4nl / ucache example snippets
e = new Em4nl\U\Cache(__DIR__ . '/cache');
// not mandatory: register cache invalidation function
$cache->invalidate(function($filename) {
// don't serve files from cache that are older than 3 hours
// (returning TRUE here means TO INVALIDATE, returning false
// or nothing means the file remains in the cache!)
return filemtime($filename) < time() - 60 * 60 * 3;
});
// try to serve from cache; if that fails, create the output and
// cache it for next time
if (!$cache->serve()) {
$cache->start();
echo 'Hello World';
$cache->end();
}