- commit
- 08a7ea0fcc98ccf80ad68aa235e6d40634c9d2bd
- parent
- b81e2fdf4fe722bc68f905494376f285bdd4f068
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2025-03-01 08:57
async_cache: evict stale entries on every call
Diffstat
M | dropin.py | 5 | ++++- |
1 files changed, 4 insertions, 1 deletions
diff --git a/dropin.py b/dropin.py
@@ -177,8 +177,11 @@ unauth = Auth() 177 177 def async_cache(func): 178 178 cache = {} 179 179 async def wrapper(*args, **kwargs): -1 180 nonlocal cache -1 181 cache = {k: v for k, v in cache.items() if v[0] < time.time()} -1 182 180 183 key = functools._make_key(args, kwargs, typed=False)181 -1 if key in cache and cache[key][0] >= time.time():-1 184 if key in cache: 182 185 return await cache[key][1] 183 186 184 187 future = asyncio.Future()