Simple-PHP-Cache
Simple-PHP-Cache copied to clipboard
expiration time not working !
i Created a php file and run this code to grab a json and store in .cache file, Everytime i refresh the php page, cache is also refreshed,
So Now shall I read the json data from the php file or from the .cache file to save api limits ?
You have to create something like this.
//Include Cache
require_once 'includes/cache.class.php';
//Create the cache
$cache = new Cache(array(
'name' => 'mycache',
'path' => 'cache/',
'extension' => '.cache'
));
$cache->eraseExpired();
if($cache->isCached("hello") === false){
echo("Save in cache -> hello <br>");
$cache->store('hello', 'Hello World!', 60); //60 Seconds
}
else{
echo("Read to cache -> hello <br>");
}
if($cache->isCached("test") === false){
echo("Save in cache -> test <br>");
$cache->store('test', 'Hello test!', 45); //45 Seconds
}
else{
echo("Read to cache -> test <br>");
}