How to use the patchy.cache.PatchingCache function in patchy

To help you get started, we’ve selected a few patchy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adamchainz / patchy / tests / test_cache.py View on Github external
def test_missing_key_error():
    cache = PatchingCache(maxsize=100)
    with pytest.raises(KeyError):
        cache.retrieve("a", "b", True)
github adamchainz / patchy / tests / test_cache.py View on Github external
def test_store_retrieve():
    cache = PatchingCache(maxsize=100)
    cache.store("a", "b", True, "c")
    assert cache.retrieve("a", "b", True) == "c"
    assert cache.retrieve("c", "b", False) == "a"
github adamchainz / patchy / tests / test_cache.py View on Github external
def test_culling():
    cache = PatchingCache(maxsize=4)
    cache.store("a", "b", True, "c")
    assert len(cache._cache) == 2
    cache.store("a", "d", True, "e")
    assert len(cache._cache) == 4
    cache.store("a", "f", True, "g")
    assert len(cache._cache) <= 4
github adamchainz / patchy / tests / test_cache.py View on Github external
def test_clear():
    cache = PatchingCache(maxsize=100)
    cache.store("a", "b", True, "c")
    cache.clear()
    with pytest.raises(KeyError):
        cache.retrieve("a", "b", True)