You are here

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

Statistics report: calculate # of set cmds and total cmds.

Overrides MemcacheStatsInterface::getSets

File

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

Class

MemcacheStatsObject
Class MemcacheStats.

Namespace

Drupal\memcache_admin\Stats

Code

public function getSets() : string {
  if (!isset($this->stats['cmd_set'])) {
    return self::NA;
  }
  if ($this->stats['cmd_set'] + $this->stats['cmd_get'] == 0) {
    $sets = 0;
  }
  else {
    $sets = $this->stats['cmd_set'] / ($this->stats['cmd_set'] + $this->stats['cmd_get']) * 100;
  }
  if (!isset($this->stats['uptime'])) {
    $average = 0;
  }
  else {
    $average = $sets / $this->stats['uptime'];
  }
  return $this
    ->t('@average/s; @set sets (@sets%) of @total commands', [
    '@average' => number_format($average, 2),
    '@sets' => number_format($sets, 2),
    '@set' => number_format($this->stats['cmd_set']),
    '@total' => number_format($this->stats['cmd_set'] + $this->stats['cmd_get']),
  ]);
}