pymemcache fixture
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m56s
Run linting on the backend code / Build (pull_request) Successful in 29s
Run testing on the backend code / Build (pull_request) Failing after 1m59s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 19s

This commit is contained in:
Helldragon67 2024-12-14 13:22:41 +01:00
parent 291edcfc2a
commit 2033941953
2 changed files with 3 additions and 10 deletions

View File

@ -132,14 +132,6 @@ def get_landmark(landmark_uuid: str) -> Landmark:
"""
try:
landmark = cache_client.get(f"landmark_{landmark_uuid}")
if not isinstance(landmark, Landmark) :
raise HTTPException(status_code=500, detail=f"Object {landmark} is not of type Landmark")
return landmark
except KeyError as exc:
raise HTTPException(status_code=404, detail="Landmark not found") from exc
except ConnectionError as exc:
raise HTTPException(status_code=503, detail="Service unavailable") from exc
except TimeoutError as exc:
raise HTTPException(status_code=504, detail="Request timed out") from exc
except Exception as exc:
raise HTTPException(status_code=500, detail="An unexpected error occurred") from exc

View File

@ -1,5 +1,5 @@
"""Module used for handling cache"""
from pymemcache import serde
from pymemcache.client.base import Client
from .constants import MEMCACHED_HOST_PATH
@ -70,5 +70,6 @@ else:
MEMCACHED_HOST_PATH,
timeout=1,
allow_unicode_keys=True,
encoding='utf-8'
encoding='utf-8',
serde=serde.pickle_serde
)