Skip to content

Commit

Permalink
fix: cache was a bad idea
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Jan 15, 2024
1 parent c5594ee commit 45a64f2
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions zonalda/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ async def ll(latitude: float, longitude: float):


GEOAPIFY_URL = "https://api.geoapify.com/v1/geocode/autocomplete"
ADDRESS_CACHE: dict[str, dict] = {}
client = httpx.AsyncClient()


Expand All @@ -96,9 +95,6 @@ async def geoloc(
filter: str | None = None,
bias: str | None = None,
):
if text in ADDRESS_CACHE:
LOGGER.info("Cache hit for '%s'", text)
return JSONResponse(ADDRESS_CACHE[text])
params = {
"text": text,
"apiKey": os.environ["GEOAPIFY_API_KEY"],
Expand All @@ -118,8 +114,7 @@ async def geoloc(
raise HTTPException(
status_code=r.status_code, detail="Échec de requête Geoapify"
)
ADDRESS_CACHE[text] = r.json()
return JSONResponse(ADDRESS_CACHE[text])
return JSONResponse(r.json())


app = FastAPI()
Expand Down

0 comments on commit 45a64f2

Please sign in to comment.