Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

perf: Higher async function cache hit

Clémence Lesné096e6d3809dd
diff --git a/app/helpers/cache.py b/app/helpers/cache.py
index cfe0f68..e9443b1 100644
--- a/app/helpers/cache.py
+++ b/app/helpers/cache.py
@@ -1,4 +1,3 @@
-import asyncio
import functools
from collections import OrderedDict
from collections.abc import AsyncGenerator, Awaitable
@@ -33,11 +32,7 @@ def async_lru_cache(maxsize: int = 128):
@functools.wraps(func)
async def wrapper(*args, **kwargs) -> Awaitable:
# Create a cache key from event loop, args and kwargs, using frozenset for kwargs to ensure hashability
- key = (
- asyncio.get_event_loop(),
- args,
- frozenset(kwargs.items()),
- )
+ key = (args, frozenset(kwargs.items()))
if key in cache:
# Move the recently accessed key to the end (most recently used)