Skip to content

Instantly share code, notes, and snippets.

@AtomicSmash
Last active December 16, 2015 17:09
Show Gist options
  • Save AtomicSmash/5468153 to your computer and use it in GitHub Desktop.
Save AtomicSmash/5468153 to your computer and use it in GitHub Desktop.
A simple transient testing setup. Saves the current time in the DB and resets it after 5 mins
//Get transient value. If it's expired it will return jolly sod all...
$teat = get_transient( 'cool_cache_name');
//See what's in the variable
if($teat == ""){
//Add the current time as a new transient, good value for testing.
//300 is equal to 5 minute - 60*60*12 is 12 hours
set_transient( 'cool_cache_name', date('G:i'), 300 );
echo(date('G:i'));
}else{
//If there is a transient in place, echo that puppy out.
echo($teat);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment