1
0
Fork 0

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
1 changed files with 9 additions and 7 deletions

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($data != false) {
echo 'updating ' . $dataSource . '<br/>';
$sourceData[$dataSource] = $data;
} else {
echo 'failed ' . $dataSource . '<br/>';
$cacheData[$dataSource] = 0;
}
}
if($sourceData != false) {
$sourceData[$dataSource] = $sourceData;
} else {
$cacheData[$dataSource] = 0;
}
}
file_put_contents(CACHE,json_encode($cacheData));