File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1233,7 +1233,7 @@ variants of :deco:`functools.lru_cache`:
12331233.. testcode ::
12341234
12351235 from collections import OrderedDict
1236- from time import time
1236+ from time import monotonic
12371237
12381238 class TimeBoundedLRU:
12391239 "LRU Cache that invalidates and refreshes old entries."
@@ -1248,10 +1248,10 @@ variants of :deco:`functools.lru_cache`:
12481248 if args in self.cache:
12491249 self.cache.move_to_end(args)
12501250 timestamp, result = self.cache[args]
1251- if time () - timestamp <= self.maxage:
1251+ if monotonic () - timestamp <= self.maxage:
12521252 return result
12531253 result = self.func(*args)
1254- self.cache[args] = time (), result
1254+ self.cache[args] = monotonic (), result
12551255 if len(self.cache) > self.maxsize:
12561256 self.cache.popitem(last=False)
12571257 return result
You can’t perform that action at this time.
0 commit comments