From 417ff4877ab52ad779cb18aee779f429ebf17efd Mon Sep 17 00:00:00 2001 From: TheByronHimes Date: Wed, 8 Jan 2025 10:44:23 +0000 Subject: [PATCH] Reduce cache TTL --- src/ghga_connector/core/client.py | 2 +- tests/unit/test_api_calls.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ghga_connector/core/client.py b/src/ghga_connector/core/client.py index a362504..ea2cd31 100644 --- a/src/ghga_connector/core/client.py +++ b/src/ghga_connector/core/client.py @@ -84,7 +84,7 @@ def get_cache_transport( """ cache_transport = hishel.AsyncCacheTransport( transport=wrapped_transport or httpx.AsyncHTTPTransport(), - storage=hishel.AsyncInMemoryStorage(ttl=86400), # persist for 24 hours + storage=hishel.AsyncInMemoryStorage(ttl=1800), # persist for 30 minutes controller=hishel.Controller( cacheable_methods=["POST", "GET"], cacheable_status_codes=[200, 201], diff --git a/tests/unit/test_api_calls.py b/tests/unit/test_api_calls.py index 86836f5..4f804e1 100644 --- a/tests/unit/test_api_calls.py +++ b/tests/unit/test_api_calls.py @@ -62,8 +62,6 @@ async def _do_request(self, method: str, *args, **kwargs) -> httpx.Response: """Wrap actual client calls so we can see which calls were cached vs not.""" method_func = getattr(super(), method) response = await method_func(*args, **kwargs) - if not self.calls: - self.calls = [] self.calls.append(response) return response @@ -121,7 +119,7 @@ async def test_get_work_order_token_caching(monkeypatch, httpx_mock: HTTPXMock): assert client.calls client.assert_last_call_not_from_cache() - # Make same call and verify that the call came from the cache instead + # Make same call and verify that the response came from the cache instead await accessor.get_work_order_token(file_id=file_id) client.assert_last_call_from_cache()