Browse Source

Support server_status cache method with php-memcached backend

spaghetti 7 years ago
parent
commit
de80d91ab6
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      classes/cache.class.php

+ 9
- 2
classes/cache.class.php View File

394
   /**
394
   /**
395
    * Get cache server status
395
    * Get cache server status
396
    *
396
    *
397
-   * @return array (host => bool status, ...)
397
+   * @return array (host => int status, ...)
398
    */
398
    */
399
   public function server_status() {
399
   public function server_status() {
400
     $Status = [];
400
     $Status = [];
401
+    if (is_subclass_of($this, 'Memcached')) {
402
+      $MemcachedStats = $this->getStats();
403
+    }
401
     foreach ($this->Servers as $Server) {
404
     foreach ($this->Servers as $Server) {
402
-      $Status["$Server[host]:$Server[port]"] = $this->getServerStatus($Server['host'], $Server['port']);
405
+      if (is_subclass_of($this, 'Memcached')) {
406
+        $Status["$Server[host]:$Server[port]"] = gettype($MemcachedStats["$Server[host]:$Server[port]"]) == 'array' ? 1 : 0;
407
+      } else {
408
+        $Status["$Server[host]:$Server[port]"] = $this->getServerStatus($Server['host'], $Server['port']);
409
+      }
403
     }
410
     }
404
     return $Status;
411
     return $Status;
405
   }
412
   }

Loading…
Cancel
Save