sentinel for cache hitting

This commit is contained in:
Shish 2023-02-02 16:52:03 +00:00
parent 9721dc8050
commit 78c56e0a57

View file

@ -28,13 +28,15 @@ class EventTracingCache implements CacheInterface
return $this->misses; return $this->misses;
} }
$sentinel = "__etc_sentinel";
$this->tracer->begin("Cache Query", ["key"=>$key]); $this->tracer->begin("Cache Query", ["key"=>$key]);
$val = $this->engine->get($key, $default); $val = $this->engine->get($key, $sentinel);
if ($val != $default) { if ($val != $sentinel) {
$res = "hit"; $res = "hit";
$this->hits++; $this->hits++;
} else { } else {
$res = "miss"; $res = "miss";
$val = $default;
$this->misses++; $this->misses++;
} }
$this->tracer->end(null, ["result"=>$res]); $this->tracer->end(null, ["result"=>$res]);