Evict expired cache entries

Python · Python · intermediate · greenfield

Adds cache eviction: iterates the cache and deletes any entry that has expired. Removes the stale keys in one pass.

Requirements

Files touched

--- app/cache/evict.py
+def evict_expired(cache: dict, now: float) -> None:
+    for key, (value, expires_at) in cache.items():
+        if expires_at <= now:
+            del cache[key]

Review this PR

Python practice