Skip to content

Commit f4f77bd

Browse files
committed
chore: drop hishel caching
Initial versions of hishel would store cache in Redis, this feature is gone and requires SQLite, which isn't thread safe and I could not find anything about it in their docs. Drop it for now. Signed-off-by: Paul Spooren <mail@aparcar.org>
1 parent 0e35bb3 commit f4f77bd

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

asu/util.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from io import BytesIO
1212
from typing import Optional
1313

14-
import hishel
1514
import nacl.signing
1615
from fastapi import FastAPI
16+
import httpx
1717
from httpx import Response
1818
from podman import PodmanClient
1919
from podman.domain.containers import Container
@@ -27,6 +27,9 @@
2727
log: logging.Logger = logging.getLogger("rq.worker")
2828
log.propagate = False # Suppress duplicate log messages.
2929

30+
# Create a shared HTTP client
31+
_http_client = httpx.Client()
32+
3033

3134
def get_redis_client(unicode: bool = True) -> redis.client.Redis:
3235
return redis.from_url(settings.redis_url, decode_responses=unicode)
@@ -36,11 +39,8 @@ def get_redis_ts():
3639
return get_redis_client().ts()
3740

3841

39-
def client_get(url: str, ttl: int = 3600) -> Response:
40-
return hishel.CacheClient(
41-
storage=hishel.RedisStorage(client=get_redis_client(False), ttl=ttl),
42-
controller=hishel.Controller(always_revalidate=True, allow_heuristics=True),
43-
).get(url)
42+
def client_get(url: str) -> Response:
43+
return _http_client.get(url)
4444

4545

4646
def add_timestamp(key: str, labels: dict[str, str] = {}, value: int = 1) -> None:
@@ -502,12 +502,6 @@ def add_versions(version_list: list, *versions: str) -> None:
502502
log.info(f".versions.json: failed to download {response.status_code}")
503503
return False
504504

505-
if response.extensions["from_cache"] and app.versions:
506-
log.debug(".versions.json: cache hit")
507-
return False
508-
509-
log.debug(".versions.json: cache miss, reloading")
510-
511505
versions_upstream = response.json()
512506
upcoming_version = versions_upstream["upcoming_version"]
513507

@@ -552,9 +546,6 @@ def reload_targets(app: FastAPI, version: str) -> bool:
552546
version_path = branch_data["path"].format(version=version)
553547
response = client_get(settings.upstream_url + f"/{version_path}/.targets.json")
554548

555-
if response.extensions["from_cache"] and app.targets[version]:
556-
return False
557-
558549
app.targets[version] = response.json() if response.status_code == 200 else {}
559550

560551
return True

0 commit comments

Comments
 (0)