From c3340e037d884fbe06bc7ae6c0b304f0f557491a Mon Sep 17 00:00:00 2001
From: Arthur Lu <learthurgo@gmail.com>
Date: Fri, 28 Feb 2025 19:21:53 +0000
Subject: [PATCH] improve tiered cache with return to l1 mechanic

---
 app/cache/tiered_cache.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/app/cache/tiered_cache.py b/app/cache/tiered_cache.py
index 39fa13e..8800e37 100644
--- a/app/cache/tiered_cache.py
+++ b/app/cache/tiered_cache.py
@@ -21,6 +21,11 @@ class TieredCache(BaselineCache):
                 f = open(self.l2_map[key], "r")
                 v = f.read()
                 f.close()
+
+                # we will also preemptively return the value from l1 to l2:
+                del self.l2_map[key]
+                self.put(key, v)
+
                 return v
             else: # otherwise its a cache miss and return None
                 return None