PHP code example of utopia-php / cache
1. Go to this page and download the library: Download utopia-php/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/ */
utopia-php / cache example snippets
topia\Cache\Cache;
use Utopia\Cache\Adapter\Filesystem;
$cache = new Cache(new Filesystem('/cache-dir'));
$key = 'data-from-example.com';
$data = $cache->load($key, 60 * 60 * 24 * 30 * 3 /* 3 months */);
if(!$data) {
$data = file_get_contents('https://example.com');
$cache->save($key, $data);
}
echo $data;