def test_cache_data_dict(): my_dict = {} c = Cache(available_bytes=nbytes(1) * 3, cache_data=my_dict) c.put('x', 1, 10) assert c.get('x') == 1 assert my_dict['x'] == 1 c.clear() assert 'x' not in c
def test_cache(): c = Cache(available_bytes=nbytes(1) * 3) c.put('x', 1, 10) assert c.get('x') == 1 assert 'x' in c c.put('a', 1, 10) c.put('b', 1, 10) c.put('c', 1, 10) assert set(c.data) == set('xbc') c.put('d', 1, 10) assert set(c.data) == set('xcd') c.clear() assert 'x' not in c assert not c.data assert not c.heap