/** * Tests the collection of a cache hit. */ public function testCacheCollectorHit() { $cache = new \StdClass(); $cache->cid = 'cache_id'; $cache->expire = 1; $cache->tags = ['tag1', 'tag2']; $this->cacheBackendInterface->expects($this->once())->method('get')->will($this->returnValue($cache)); $cacheBackendWrapper = new CacheBackendWrapper($this->cacheDataCollector, $this->cacheBackendInterface, 'default'); $cache2 = $cacheBackendWrapper->get('cache_id'); $this->assertNotNull($cache2); $this->assertEquals(1, $this->cacheDataCollector->getCacheHitsCount()); }
/** * {@inheritdoc} */ public function getMultiple(&$cids, $allow_invalid = FALSE) { $cidsCopy = $cids; $cache = $this->cacheBackend->getMultiple($cids, $allow_invalid); foreach ($cidsCopy as $cid) { if (in_array($cid, $cids)) { $this->cacheDataCollector->registerCacheMiss($this->bin, $cid); } else { $cacheCopy = new \StdClass(); $cacheCopy->cid = $cache[$cid]->cid; $cacheCopy->expire = $cache[$cid]->expire; $cacheCopy->tags = $cache[$cid]->tags; $this->cacheDataCollector->registerCacheHit($this->bin, $cacheCopy); } } return $cache; }