From cee9d2d7ba004dc721fe5947ba2a6afc9fb7952a Mon Sep 17 00:00:00 2001 From: Scott Trinh Date: Thu, 18 Jan 2024 16:08:45 -0500 Subject: [PATCH] Use newly released hishel in-memory cache (#6644) --- edb/server/protocol/auth_ext/http_client.py | 20 ++------------------ pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/edb/server/protocol/auth_ext/http_client.py b/edb/server/protocol/auth_ext/http_client.py index 55c3666836d..8becb135cf0 100644 --- a/edb/server/protocol/auth_ext/http_client.py +++ b/edb/server/protocol/auth_ext/http_client.py @@ -21,8 +21,6 @@ import hishel import httpx -from edb.common import lru - class HttpClient(httpx.AsyncClient): def __init__( @@ -33,7 +31,8 @@ def __init__( self.edgedb_orig_base_url = urllib.parse.quote(base_url, safe='') base_url = edgedb_test_url cache = hishel.AsyncCacheTransport( - transport=httpx.AsyncHTTPTransport(), storage=InMemoryStorage() + transport=httpx.AsyncHTTPTransport(), + storage=hishel.AsyncInMemoryStorage(capacity=5), ) super().__init__(*args, base_url=base_url, transport=cache, **kwargs) @@ -46,18 +45,3 @@ async def get(self, path, *args, **kwargs): if self.edgedb_orig_base_url: path = f'{self.edgedb_orig_base_url}/{path}' return await super().get(path, *args, **kwargs) - - -class InMemoryStorage(hishel._async._storages.AsyncBaseStorage): - def __init__(self, maxsize=5): - super().__init__() - self._storage = lru.LRUMapping(maxsize=maxsize) - - async def store(self, key: str, response, request, metadata): - self._storage[key] = (response, request, metadata) - - async def retreive(self, key: str): - return self._storage.get(key, None) - - async def aclose(self): - pass diff --git a/pyproject.toml b/pyproject.toml index 9fa92bed215..be33386d259 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ dependencies = [ 'setproctitle~=1.2', 'httpx~=0.24.1', - 'hishel==0.0.18', + 'hishel==0.0.21', 'argon2-cffi~=23.1.0', 'aiosmtplib~=2.0', ]