skyzyx
8/8/2010 - 4:56 PM

gistfile1.php

<?php
require_once "cloudfusion.class.php";

function callback($input)
{
	/*
	Make requests and process input. Return the data that you want to see cached.
	SimpleXML objects must be converted back into strings before returning.
		
	If the HTTP request failed or did not return the correct data, or you are otherwise 
	unable to process the data correctly, return null. This will tell response_manager() 
	to keep the existing cache until a successful request can be made.
		
	This callback function is only called when (a) there is no cache data, or (b) when
	the cache data has already expired.
	*/
}

// Instantiate a new file-system-based cache that expires in an hour.
$cache = new CacheFile('test', './cache', 3600);

/*
Retrieve the data from either the cache or the server
 -- whichever is available, in that order. Parameters
are passed in as an array in the second parameter.
*/
$result = $cache->response_manager('callback', array($input));

echo $result;