mirror of
https://github.com/ltcptgeneral/cs239-caching.git
synced 2025-09-08 00:07:22 +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")
|
f = open(self.l2_map[key], "r")
|
||||||
v = f.read()
|
v = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
# we will also preemptively return the value from l1 to l2:
|
||||||
|
del self.l2_map[key]
|
||||||
|
self.put(key, v)
|
||||||
|
|
||||||
return v
|
return v
|
||||||
else: # otherwise its a cache miss and return None
|
else: # otherwise its a cache miss and return None
|
||||||
return None
|
return None
|
||||||
|
Reference in New Issue
Block a user