From a6ee917797c55ebb176e2ed332c3dc19c99b19a5 Mon Sep 17 00:00:00 2001 From: Mason McElvain <52104630+masonmcelvain@users.noreply.github.com> Date: Fri, 1 Aug 2025 11:15:04 -0700 Subject: [PATCH] feat: disableCacheGets once per key --- .../iFixit/Matryoshka/DisableCacheGets.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 library/iFixit/Matryoshka/DisableCacheGets.php diff --git a/library/iFixit/Matryoshka/DisableCacheGets.php b/library/iFixit/Matryoshka/DisableCacheGets.php new file mode 100644 index 0000000..b63e9c9 --- /dev/null +++ b/library/iFixit/Matryoshka/DisableCacheGets.php @@ -0,0 +1,38 @@ +backend = $backend; + $this->gets = []; + } + + public function get($key) { + if ($this->gets[$key] ?? null) { + return $this->backend->get($key); + } else { + $this->gets[$key] = true; + return self::MISS; + } + } + + public function getMultiple(array $keys) { + $found = []; + foreach ($keys as $key => $_) { + if ($this->gets[$key] ?? null) { + $found[$key] = $this->backend->get($key); + } else { + $this->gets[$key] = true; + $found[$key] = self::MISS; + } + } + return [$found, $keys]; + } +}