From 78c56e0a578aae6d63149ee908991f4900b5ec79 Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 2 Feb 2023 16:52:03 +0000 Subject: [PATCH] sentinel for cache hitting --- core/cacheengine.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/cacheengine.php b/core/cacheengine.php index 2589689e..60f4cac4 100644 --- a/core/cacheengine.php +++ b/core/cacheengine.php @@ -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]);