PHP code example of anekdotes / cache
1. Go to this page and download the library: Download anekdotes/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/ */
anekdotes / cache example snippets
use Anekdotes\Cache\FileCache;
$path = 'tmp/cache/'; //The slash at the end is IMPORTANT. MAKE SURE YOU HAVE IT!
$cache = new FileCache($path);
$key = 'Toaster';
$value = 'Test';
$minutes = 5;
$cache->set($key, $value, $minutes);
$cache->get('Toaster'); //Returns 'Test' as long as this call is made in a 5 minute time-frame past the previous set call.
$cache->time('Toaster'); //Return the datetime object of when this key has been set
$cache->forget('Toaster');
$cache->has('Toaster'); //Returns false.