Browse Source

Support server_status cache method with php-memcached backend

spaghetti 1 year 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,12 +394,19 @@ class Cache extends MemcacheCompat {
394 394
   /**
395 395
    * Get cache server status
396 396
    *
397
-   * @return array (host => bool status, ...)
397
+   * @return array (host => int status, ...)
398 398
    */
399 399
   public function server_status() {
400 400
     $Status = [];
401
+    if (is_subclass_of($this, 'Memcached')) {
402
+      $MemcachedStats = $this->getStats();
403
+    }
401 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 411
     return $Status;
405 412
   }

Loading…
Cancel
Save