Exemple #1
0
def test_cache_clear(cache: Cache):
    """Test that cache.clear() deletes all cache keys."""
    items = {"a": 1, "b": 2, "c": 3}
    cache.set_many(items)
    assert len(cache) == len(items)

    cache.clear()
    assert len(cache) == 0
Exemple #2
0
    return a + b


@cache.memoize()
def func(a, b):
    pass


func.uncached(1, 2)

assert cache.copy() == {1: "foobar", 2: ("foo", "bar", "baz")}

cache.delete(1)
assert cache.get(1) is None

cache.clear()
assert len(cache) == 0

cache.set_many({"a": 1, "b": 2, "c": 3})
assert cache.get_many(["a", "b", "c"]) == {"a": 1, "b": 2, "c": 3}
cache.delete_many(["a", "b", "c"])
assert cache.count() == 0

import re

cache.set_many({"a_1": 1, "a_2": 2, "123": 3, "b": 4})

# func.uncached(1, 2)

# assert cache.copy() == {1: "foobar", 2: ("foo", "bar", "baz")}