You are here

protected function DriverBase::statsWrite in Memcache API and Integration 8.2

Memcache statistics to be displayed at end of page generation.

Parameters

string $action: The action being performed (get, set, etc...).

string $bin: The memcache bin the action is being performed in.

array $keys: Keyed array in the form (string)$cid => (bool)$success. The keys the action is being performed on, and whether or not it was a success.

9 calls to DriverBase::statsWrite()
DriverBase::delete in src/Driver/DriverBase.php
Deletes an item from Memcache.
DriverBase::flush in src/Driver/DriverBase.php
Immediately invalidates all existing items.
DriverBase::get in src/Driver/DriverBase.php
Retrieves a value from Memcache.
MemcachedDriver::add in src/Driver/MemcachedDriver.php
Add an item to Memcache if it doesn't exist already.
MemcachedDriver::getMulti in src/Driver/MemcachedDriver.php
Retrieves multiple values from Memcache.

... See full list

File

src/Driver/DriverBase.php, line 332

Class

DriverBase
Class DriverBase.

Namespace

Drupal\memcache\Driver

Code

protected function statsWrite($action, $bin, array $keys) {

  // Determine how much time elapsed to execute this action.
  $time = Timer::read('dmemcache');

  // Build the 'all' and 'ops' arrays displayed by memcache_admin.module.
  foreach ($keys as $key => $success) {
    self::$stats['all'][] = [
      number_format($time, 2),
      $action,
      $bin,
      $key,
      $success ? 'hit' : 'miss',
    ];
    if (!isset(self::$stats['ops'][$action])) {
      self::$stats['ops'][$action] = [
        $action,
        0,
        0,
        0,
      ];
    }
    self::$stats['ops'][$action][1] += $time;
    if ($success) {
      self::$stats['ops'][$action][2]++;
    }
    else {
      self::$stats['ops'][$action][3]++;
    }
  }
}