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]; + } +}