mirror of
https://github.com/ltcptgeneral/cs239-caching.git
synced 2025-09-07 15:57:23 +00:00
improve tiered cache with return to l1 mechanic
This commit is contained in:
5
app/cache/tiered_cache.py
vendored
5
app/cache/tiered_cache.py
vendored
@@ -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
|
||||
|
Reference in New Issue
Block a user