ai-gateway / tests /test_cache.py
basyx's picture
Upload 58 files
36333c5 verified
Raw
History Blame Contribute Delete
388 Bytes
"""Bounded cache behavior."""
from core.cache import LRUCache
def test_lru_cache_promotes_reads_before_eviction() -> None:
cache: LRUCache[str, int] = LRUCache(capacity=2)
assert cache.put("a", 1) is None
assert cache.put("b", 2) is None
assert cache.get("a") == 1
assert cache.put("c", 3) == ("b", 2)
assert cache.get("a") == 1
assert cache.get("c") == 3