Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@


class SimpleCache[VT, *KTs]:
_cache: dict[tuple[*KTs], tuple[int, VT]] = {}
def __init__(self) -> None:
# per instance, otherwise every cache in the app shares one dict
self._cache: dict[tuple[*KTs], tuple[int, VT]] = {}

def get(self, source_ttl: int, *query: *KTs) -> VT | None:
hit = self._cache.get(query)
Expand Down Expand Up @@ -35,7 +37,9 @@ def flush(self):


class StringConfigCache[L: str]:
_cache: dict[L, str] = {}
def __init__(self) -> None:
# per instance, otherwise every config in the app shares one dict
self._cache: dict[L, str] = {}

@overload
def get(self, session: Session, key: L) -> str | None: ...
Expand Down