Make sure not to write data unless we need to.

This commit is contained in:
Andrew Tomaka 2011-10-17 21:01:30 -04:00
parent 73c1e11e71
commit 529fcdc81d

View file

@ -61,14 +61,16 @@ foreach($dataSources as $dataSource=>$refreshTime) {
if(time() - $lastModified > $refreshTime) {
$cacheData[$dataSource] = time();
$sourceData = call_user_func($dataSource);
}
$data = call_user_func($dataSource);
if($sourceData != false) {
$sourceData[$dataSource] = $sourceData;
} else {
$cacheData[$dataSource] = 0;
}
if($data != false) {
echo 'updating ' . $dataSource . '<br/>';
$sourceData[$dataSource] = $data;
} else {
echo 'failed ' . $dataSource . '<br/>';
$cacheData[$dataSource] = 0;
}
}
}
file_put_contents(CACHE,json_encode($cacheData));