Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9461750

Browse filesBrowse files
[Cache] Drop counting hit/miss in ProxyAdapter
1 parent 7dc1491 commit 9461750
Copy full SHA for 9461750

File tree

2 files changed

+2
-51
lines changed
Filter options

2 files changed

+2
-51
lines changed

‎src/Symfony/Component/Cache/Adapter/ProxyAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/ProxyAdapter.php
+2-34Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class ProxyAdapter implements AdapterInterface
2424
private $namespace;
2525
private $namespaceLen;
2626
private $createCacheItem;
27-
private $hits = 0;
28-
private $misses = 0;
2927

3028
public function __construct(CacheItemPoolInterface $pool, $namespace = '', $defaultLifetime = 0)
3129
{
@@ -54,13 +52,8 @@ public function getItem($key)
5452
{
5553
$f = $this->createCacheItem;
5654
$item = $this->pool->getItem($this->getId($key));
57-
if ($isHit = $item->isHit()) {
58-
++$this->hits;
59-
} else {
60-
++$this->misses;
61-
}
6255

63-
return $f($key, $item->get(), $isHit);
56+
return $f($key, $item->get(), $item->isHit());
6457
}
6558

6659
/**
@@ -158,39 +151,14 @@ private function generateItems($items)
158151
$f = $this->createCacheItem;
159152

160153
foreach ($items as $key => $item) {
161-
if ($isHit = $item->isHit()) {
162-
++$this->hits;
163-
} else {
164-
++$this->misses;
165-
}
166154
if ($this->namespaceLen) {
167155
$key = substr($key, $this->namespaceLen);
168156
}
169157

170-
yield $key => $f($key, $item->get(), $isHit);
158+
yield $key => $f($key, $item->get(), $item->isHit());
171159
}
172160
}
173161

174-
/**
175-
* Returns the number of cache read hits.
176-
*
177-
* @return int
178-
*/
179-
public function getHits()
180-
{
181-
return $this->hits;
182-
}
183-
184-
/**
185-
* Returns the number of cache read misses.
186-
*
187-
* @return int
188-
*/
189-
public function getMisses()
190-
{
191-
return $this->misses;
192-
}
193-
194162
private function getId($key)
195163
{
196164
CacheItem::validateKey($key);

‎src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterTest.php
-17Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,4 @@ public function createCachePool()
2929
{
3030
return new ProxyAdapter(new ArrayAdapter());
3131
}
32-
33-
public function testGetHitsMisses()
34-
{
35-
$pool = $this->createCachePool();
36-
37-
$this->assertSame(0, $pool->getHits());
38-
$this->assertSame(0, $pool->getMisses());
39-
40-
$bar = $pool->getItem('bar');
41-
$this->assertSame(0, $pool->getHits());
42-
$this->assertSame(1, $pool->getMisses());
43-
44-
$pool->save($bar->set('baz'));
45-
$bar = $pool->getItem('bar');
46-
$this->assertSame(1, $pool->getHits());
47-
$this->assertSame(1, $pool->getMisses());
48-
}
4932
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.