Closed
Description
I got the following error while writing unit-tests. Interestingly I got the error only with size=1
or size=2
. So I hope it only impacts testing and not real life, but that's still unexpected.
from datetime import timedelta
from theine import Cache
def test(size):
cache = Cache('tlfu', size)
# set 1 and get it many times to make it the most frequently used
cache.set(1, 1, timedelta(seconds=1000))
for _ in range(10 * size):
assert cache.get(1) == 1
# fill the cache with keys that are never read again
for i in range(10 * size):
cache.set(i, i, timedelta(seconds=1000))
# get 1 again
# note that I do not get the panic error if you remove the next line
assert cache.get(1) == 1
# try to write dummy keys again
for i in range(10 * size):
cache.set(i, i, timedelta(seconds=1000))
test(2) # raises
test(3) # ok
raises:
thread '<unnamed>' panicked at 'link id not match', src/metadata.rs:159:13
stack backtrace:
[...]
10: 0x1022dcd63 - core::panicking::panic_fmt::hc10ef4c7e7c3da2e
11: 0x102290ac5 - theine_core::metadata::Link::remove_wheel::hac48c6eac45dc96a
12: 0x10228dfbb - theine_core::core::TlfuCore::set::h794298ae1966b4d2
13: 0x10228b809 - std::panicking::try::hec7d762371985e37
[...]
Metadata
Metadata
Assignees
Labels
No labels