Skip to content

Commit 4a002d8

Browse files
committed
-
1 parent b0ff8ef commit 4a002d8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

python_toolbox/caching/decorators.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ def decorator(function):
9595

9696

9797
def remove_expired_entries():
98-
cutting_point = binary_search.binary_search_by_index(
98+
almost_cutting_point = \
99+
binary_search.binary_search_by_index(
99100
cached._cache.keys(),
100101
sorting_key_function,
101102
_get_now(),
102103
rounding=binary_search.LOW
103104
)
104-
if cutting_point is not None:
105+
if almost_cutting_point is not None:
106+
cutting_point = almost_cutting_point + 1
105107
for key in cached._cache.keys()[:cutting_point]:
106108
del cached._cache[key]
107109

@@ -116,7 +118,7 @@ def cached(function, *args, **kwargs):
116118
value = function(*args, **kwargs)
117119
cached._cache[sleek_call_args] = (
118120
value,
119-
_get_now()
121+
_get_now() + time_to_keep
120122
)
121123
cached._cache.sort(key=sorting_key_function)
122124
return value

0 commit comments

Comments
 (0)