You are here

public function MemcacheStatsObject::getMemory in Memcache API and Integration 8.2

@inheritDoc

Overrides MemcacheStatsInterface::getMemory

1 method overrides MemcacheStatsObject::getMemory()
McrouterStatsObject::getMemory in memcache_admin/src/Stats/McrouterStatsObject.php
@inheritDoc

File

memcache_admin/src/Stats/MemcacheStatsObject.php, line 234

Class

MemcacheStatsObject
Class MemcacheStats.

Namespace

Drupal\memcache_admin\Stats

Code

public function getMemory() : string {
  if (!isset($this->stats['limit_maxbytes']) || !isset($this->stats['bytes'])) {
    return self::NA;
  }
  if ($this->stats['limit_maxbytes'] == 0) {
    $percent = 0;
  }
  else {
    $percent = 100 - $this->stats['bytes'] / $this->stats['limit_maxbytes'] * 100;
  }
  return $this
    ->t('@available (@percent%) of @total', [
    '@available' => format_size($this->stats['limit_maxbytes'] - $this->stats['bytes']),
    '@percent' => number_format($percent, 2),
    '@total' => format_size($this->stats['limit_maxbytes']),
  ]);
}