PHP code example of andydune / retain-cache-on-data-absent
1. Go to this page and download the library: Download andydune/retain-cache-on-data-absent 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/ */
andydune / retain-cache-on-data-absent example snippets
use Symfony\Component\Cache\Simple\FilesystemCache;
use AndyDune\RetainCacheOnDataAbsent\Cache;
$cacheAdapter = new FilesystemCache('test', 3600, '<root cache dir>');
$cache = new Cache($cacheAdapter, function () {
/*
$data = false; // no data - return data from old cache
$data = 'very useful data to cache and use'; // update cache and return this data
*/
return $data;
});
$result = $cache->get('data'); // use any key - it is used only for cache key
php composer.phar update