Make sure not to write data unless we need to.
This commit is contained in:
parent
73c1e11e71
commit
529fcdc81d
1 changed files with 9 additions and 7 deletions
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue