From: hickert Date: Wed, 10 Nov 2010 09:57:07 +0000 (+0000) Subject: Added caching to the registration detectiom. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3dce8a0edaa85123c36c99084c5a2a768a253c3f;p=gosa.git Added caching to the registration detectiom. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20220 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_GOsaRegistration.inc b/gosa-core/include/class_GOsaRegistration.inc index 904ca664f..81433a959 100644 --- a/gosa-core/include/class_GOsaRegistration.inc +++ b/gosa-core/include/class_GOsaRegistration.inc @@ -32,15 +32,24 @@ class GOsaRegistration } } - function isServerAccessible() + function isServerAccessible($force = FALSE) { - $con = $this->getConnection(); - $res = $con->isInstanceRegistered("dummy"); - if($con->success()){ - return(TRUE); - }else{ - return(FALSE); + // Only request a new status every 2 seconds + if(isset($this->cache['isServerAccessible']['called']) && !$force){ + if($this->cache['isServerAccessible']['called'] + 2 > time()){ + return($this->cache['isServerAccessible']['result']); } + } + + // Check the connection status by calling a dummy function + $con = $this->getConnection(); + $res = $con->isInstanceRegistered("dummy"); + + // Store the result + $this->cache['isServerAccessible']['called'] = time(); + $this->cache['isServerAccessible']['result'] = $con->success(); + + return($con->success()); } function registrationNotWanted()