Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
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