Refactor Appbox

This commit is contained in:
Romain Neutron
2012-02-21 16:09:34 +01:00
parent 6ce734c50d
commit 1d6eb86c90
5 changed files with 21 additions and 11 deletions

View File

@@ -17,7 +17,7 @@
*/
class cache_databox
{
protected static $refreshing = false;
/**
*
* @param int $sbas_id
@@ -25,11 +25,18 @@ class cache_databox
*/
public static function refresh($sbas_id)
{
if(self::$refreshing)
{
return;
}
self::$refreshing = true;
$databox = \databox::get_instance((int) $sbas_id);
$date = new \DateTime('-3 seconds');
$appbox = \appbox::get_instance();
$appbox = \appbox::get_instance(\bootstrap::getCore());
$registry = \registry::get_instance();
@@ -49,8 +56,9 @@ class cache_databox
else
$last_update = new \DateTime('-10 years');
if ($date <= $last_update || !$appbox->get_cache()->ping())
if ($date <= $last_update)
{
self::$refreshing = false;
return;
}
@@ -136,6 +144,8 @@ class cache_databox
$stmt->execute(array(':date' => $now));
$stmt->closeCursor();
self::$refreshing = false;
return;
}