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;
}
$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]);