mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-08 02:37:52 +02:00
Lint
This commit is contained in:
+8
-8
@@ -21,22 +21,22 @@ class BaseCache(ABC, Generic[T]):
|
||||
def get(self, keys: Sequence[str]) -> dict[str, T]:
|
||||
"""Get the cached values for the given keys."""
|
||||
|
||||
@abstractmethod
|
||||
def set(self, mapping: Mapping[str, tuple[T, int | None]]) -> None:
|
||||
"""Set the cached values for the given keys and TTLs."""
|
||||
|
||||
@abstractmethod
|
||||
def delete(self, keys: Sequence[str]) -> None:
|
||||
"""Delete the cached values for the given keys."""
|
||||
|
||||
@abstractmethod
|
||||
async def aget(self, keys: Sequence[str]) -> dict[str, T]:
|
||||
"""Asynchronously get the cached values for the given keys."""
|
||||
|
||||
@abstractmethod
|
||||
def set(self, mapping: Mapping[str, tuple[T, int | None]]) -> None:
|
||||
"""Set the cached values for the given keys and TTLs."""
|
||||
|
||||
@abstractmethod
|
||||
async def aset(self, mapping: Mapping[str, tuple[T, int | None]]) -> None:
|
||||
"""Asynchronously set the cached values for the given keys and TTLs."""
|
||||
|
||||
@abstractmethod
|
||||
def delete(self, keys: Sequence[str]) -> None:
|
||||
"""Delete the cached values for the given keys."""
|
||||
|
||||
@abstractmethod
|
||||
async def adelete(self, keys: Sequence[str]) -> None:
|
||||
"""Asynchronously delete the cached values for the given keys."""
|
||||
|
||||
+8
-8
@@ -28,25 +28,25 @@ class FileCache(BaseCache):
|
||||
if key in self._db
|
||||
}
|
||||
|
||||
async def aget(self, keys: list[str]) -> dict[str, bytes]:
|
||||
"""Asynchronously get the cached values for the given keys."""
|
||||
return await asyncio.to_thread(self.get, keys)
|
||||
|
||||
def set(self, mapping: dict[str, tuple[bytes, int | None]]) -> None:
|
||||
"""Set the cached values for the given keys and TTLs."""
|
||||
for key, (value, _) in mapping.items():
|
||||
# File-based caches do not support TTLs, so we ignore them.
|
||||
self._db[key] = ormsgpack.packb(self.serde.dumps_typed(value))
|
||||
|
||||
async def aset(self, mapping: dict[str, tuple[bytes, int | None]]) -> None:
|
||||
"""Asynchronously set the cached values for the given keys and TTLs."""
|
||||
await asyncio.to_thread(self.set, mapping)
|
||||
|
||||
def delete(self, keys: list[str]) -> None:
|
||||
"""Delete the cached values for the given keys."""
|
||||
for key in keys:
|
||||
self._db.pop(key, None)
|
||||
|
||||
async def aget(self, keys: list[str]) -> dict[str, bytes]:
|
||||
"""Asynchronously get the cached values for the given keys."""
|
||||
return await asyncio.to_thread(self.get, keys)
|
||||
|
||||
async def aset(self, mapping: dict[str, tuple[bytes, int | None]]) -> None:
|
||||
"""Asynchronously set the cached values for the given keys and TTLs."""
|
||||
await asyncio.to_thread(self.set, mapping)
|
||||
|
||||
async def adelete(self, keys: list[str]) -> None:
|
||||
"""Asynchronously delete the cached values for the given keys."""
|
||||
await asyncio.to_thread(self.delete, keys)
|
||||
|
||||
Reference in New Issue
Block a user