Skip to content

Commit

Permalink
Reduce cache TTL
Browse files Browse the repository at this point in the history
  • Loading branch information
TheByronHimes committed Jan 8, 2025
1 parent e373e9e commit 417ff48
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ghga_connector/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/test_api_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 417ff48

Please sign in to comment.