Exemplo n.º 1
0
    def test_max_size(self):
        cache = ExpiringCache(max_size=5)
        cache['foo1'] = 1
        cache['foo2'] = 1
        cache['foo3'] = 1
        cache['foo4'] = 1
        cache['foo5'] = 1

        assert list(cache.keys()) == ['foo1', 'foo2', 'foo3', 'foo4', 'foo5']

        cache['foo6'] = 1

        assert list(cache.keys()) == ['foo2', 'foo3', 'foo4', 'foo5', 'foo6']
Exemplo n.º 2
0
    def test_max_size(self):
        cache = ExpiringCache(max_size=5)
        cache["foo1"] = 1
        cache["foo2"] = 1
        cache["foo3"] = 1
        cache["foo4"] = 1
        cache["foo5"] = 1

        assert list(cache.keys()) == ["foo1", "foo2", "foo3", "foo4", "foo5"]

        cache["foo6"] = 1

        assert list(cache.keys()) == ["foo2", "foo3", "foo4", "foo5", "foo6"]