Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expiration time not working ! #17

Open
indiarocks08 opened this issue Apr 30, 2015 · 1 comment
Open

expiration time not working ! #17

indiarocks08 opened this issue Apr 30, 2015 · 1 comment

Comments

@indiarocks08
Copy link

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 ?

@indiarocks08 indiarocks08 changed the title how to grab json feed url using this function? expiration time not working ! Apr 30, 2015
@mtreik
Copy link

mtreik commented Jul 6, 2016

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>");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants