Add async methods to InMemoryCache (#17425)

Add async methods to InMemoryCache
This commit is contained in:
Christophe Bornet 2024-02-13 04:02:38 +01:00 committed by GitHub
parent 93472ee9e6
commit fb7552bfcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -192,6 +192,20 @@ class InMemoryCache(BaseCache):
"""Clear cache."""
self._cache = {}
async def alookup(self, prompt: str, llm_string: str) -> Optional[RETURN_VAL_TYPE]:
"""Look up based on prompt and llm_string."""
return self.lookup(prompt, llm_string)
async def aupdate(
self, prompt: str, llm_string: str, return_val: RETURN_VAL_TYPE
) -> None:
"""Update cache based on prompt and llm_string."""
self.update(prompt, llm_string, return_val)
async def aclear(self, **kwargs: Any) -> None:
"""Clear cache."""
self.clear()
Base = declarative_base()