Code

Added caching to the registration detectiom.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Nov 2010 09:57:07 +0000 (09:57 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Nov 2010 09:57:07 +0000 (09:57 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20220 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_GOsaRegistration.inc

index 904ca664f0ac367e19a7fa72168146051c70a747..81433a95964f14553ed461b7fb49dbbaf71c8b02 100644 (file)
@@ -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()