function MemoryCounterBackend::getCounter

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Cache/MemoryCounterBackend.php \Drupal\Core\Cache\MemoryCounterBackend::getCounter()
  2. 8.9.x core/lib/Drupal/Core/Cache/MemoryCounterBackend.php \Drupal\Core\Cache\MemoryCounterBackend::getCounter()
  3. 10 core/lib/Drupal/Core/Cache/MemoryCounterBackend.php \Drupal\Core\Cache\MemoryCounterBackend::getCounter()

Returns the call counter for the get, set and delete methods.

Parameters

string $method: (optional) The name of the method to return the call counter for.

string $cid: (optional) The name of the cache id to return the call counter for.

Return value

int|array An integer if both method and cid is given, an array otherwise.

File

core/lib/Drupal/Core/Cache/MemoryCounterBackend.php, line 74

Class

MemoryCounterBackend
Defines a memory cache implementation that counts set and get calls.

Namespace

Drupal\Core\Cache

Code

public function getCounter($method = NULL, $cid = NULL) {
    if ($method && $cid) {
        return $this->counter[$method][$cid] ?? 0;
    }
    elseif ($method) {
        return $this->counter[$method] ?? [];
    }
    else {
        return $this->counter;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.