Skip to content

Instantly share code, notes, and snippets.

@moskowite
Created January 11, 2012 23:06
Show Gist options
  • Save moskowite/1597357 to your computer and use it in GitHub Desktop.
Save moskowite/1597357 to your computer and use it in GitHub Desktop.
// 60 seconds * 60 minutes * 24 hours = 1 day refresh
$refreshInterval = 60*60*24;
$input = range(1,30);
$arr = array_rand($input, 4);
if ( false === ( $featured_products = get_transient( 'featured_products' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$request_url = 'http://makershed.com/net/webservice.aspx?api_name=generic\featured_products';
$xml = simplexml_load_file($request_url);
$featured_products = $xml->Product;
set_transient('featured_products', $featured_products, $refreshInterval );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment