mirror of
https://github.com/ltcptgeneral/cs239-caching.git
synced 2025-04-01 20:33:26 +00:00
improve tiered cache with return to l1 mechanic
This commit is contained in:
parent
f7903f4fea
commit
c3340e037d
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user