sentinel for cache hitting
This commit is contained in:
parent
9721dc8050
commit
78c56e0a57
1 changed files with 4 additions and 2 deletions
|
@ -28,13 +28,15 @@ class EventTracingCache implements CacheInterface
|
|||
return $this->misses;
|
||||
}
|
||||
|
||||
$sentinel = "__etc_sentinel";
|
||||
$this->tracer->begin("Cache Query", ["key"=>$key]);
|
||||
$val = $this->engine->get($key, $default);
|
||||
if ($val != $default) {
|
||||
$val = $this->engine->get($key, $sentinel);
|
||||
if ($val != $sentinel) {
|
||||
$res = "hit";
|
||||
$this->hits++;
|
||||
} else {
|
||||
$res = "miss";
|
||||
$val = $default;
|
||||
$this->misses++;
|
||||
}
|
||||
$this->tracer->end(null, ["result"=>$res]);
|
||||
|
|
Reference in a new issue