File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1229,7 +1229,7 @@ variants of :func:`functools.lru_cache`:
12291229.. testcode ::
12301230
12311231 from collections import OrderedDict
1232- from time import time
1232+ from time import monotonic
12331233
12341234 class TimeBoundedLRU:
12351235 "LRU Cache that invalidates and refreshes old entries."
@@ -1244,10 +1244,10 @@ variants of :func:`functools.lru_cache`:
12441244 if args in self.cache:
12451245 self.cache.move_to_end(args)
12461246 timestamp, result = self.cache[args]
1247- if time () - timestamp <= self.maxage:
1247+ if monotonic () - timestamp <= self.maxage:
12481248 return result
12491249 result = self.func(*args)
1250- self.cache[args] = time (), result
1250+ self.cache[args] = monotonic (), result
12511251 if len(self.cache) > self.maxsize:
12521252 self.cache.popitem(last=False)
12531253 return result
You can’t perform that action at this time.
0 commit comments