Skip to content

Commit 8a32a75

Browse files
committed
-
1 parent 60e18ec commit 8a32a75

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

python_toolbox/caching/cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ def decorator(function):
8282

8383
cache_dict = OrderedDict()
8484
sorting_key_function = lambda sleek_call_args: \
85-
cached._cache[sleek_call_args][0]
85+
cached._cache[sleek_call_args][1]
8686

8787

8888
def remove_expired_entries():
8989
cutting_point = binary_search.binary_search_by_index(
90-
cached._cache,
90+
cached._cache.keys(),
9191
sorting_key_function,
9292
datetime_module.datetime.now(),
9393
rounding=binary_search.LOW

test_python_toolbox/test_caching/test_cache.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ def test_double_caching():
191191

192192

193193
def test_time_to_keep():
194-
f = cache(time_to_keep={'years': 1})(counting_func)
194+
f = cache(time_to_keep={'days': 356})(counting_func)
195+
196+
assert f('zero') == 0 # Just to get rid of zero
195197

196198
assert f('a') == 1
197199
assert f('b') == 2
@@ -221,7 +223,8 @@ def _mock_now():
221223
fixed_time += datetime_module.timedelta(days=100)
222224
assert map(f, 'abc') == (7, 8, 9)
223225
assert map(f, 'def') == (10, 11, 12)
226+
assert f(a='d') == f(a='d', b=2) == f('d') == 10
224227
fixed_time += datetime_module.timedelta(days=1000)
225228
assert map(f, 'abcdef') == (13, 14, 15, 16, 17, 18)
226-
227-
229+
assert f(a='d', b='meow') == 19
230+

0 commit comments

Comments
 (0)