You are here

public function CacheDataCollector::registerCacheHit in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/CacheDataCollector.php \Drupal\webprofiler\DataCollector\CacheDataCollector::registerCacheHit()
  2. 8 webprofiler/src/DataCollector/CacheDataCollector.php \Drupal\webprofiler\DataCollector\CacheDataCollector::registerCacheHit()
  3. 8.2 webprofiler/src/DataCollector/CacheDataCollector.php \Drupal\webprofiler\DataCollector\CacheDataCollector::registerCacheHit()

Registers a cache get on a specific cache bin.

Parameters

$cache:

File

webprofiler/src/DataCollector/CacheDataCollector.php, line 41

Class

CacheDataCollector
Collects the used cache bins and cache CIDs.

Namespace

Drupal\webprofiler\DataCollector

Code

public function registerCacheHit($bin, $cache) {
  $current = isset($this->data['cache'][$bin][$cache->cid]) ? $this->data['cache'][$bin][$cache->cid] : NULL;
  if (!$current) {
    $current = $cache;
    $current->{CacheDataCollector::WEBPROFILER_CACHE_HIT} = 0;
    $current->{CacheDataCollector::WEBPROFILER_CACHE_MISS} = 0;
    $this->data['cache'][$bin][$cache->cid] = $current;
  }
  $current->{CacheDataCollector::WEBPROFILER_CACHE_HIT}++;
  $this->data['total'][CacheDataCollector::WEBPROFILER_CACHE_HIT]++;
}