Skip to content

Commit

Permalink
Try and do writing to cache in background task
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdp committed Sep 29, 2023
1 parent 2265f36 commit f29104c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/src/backend/primary/routers/surface/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from . import schemas

from src.backend.caching import CACHE
from fastapi import BackgroundTasks



Expand Down Expand Up @@ -58,6 +59,7 @@ def get_surface_directory(

@router.get("/realization_surface_data/")
async def get_realization_surface_data(
background_tasks: BackgroundTasks,
authenticated_user: AuthenticatedUser = Depends(AuthHelper.get_authenticated_user),
case_uuid: str = Query(description="Sumo case uuid"),
ensemble_name: str = Query(description="Ensemble name"),
Expand Down Expand Up @@ -94,7 +96,8 @@ async def get_realization_surface_data(
#await CACHE.set_Any(cache_key, surf_data_response)

if not cached_xtgeo_surf:
await CACHE.set_RegularSurface(cache_key, xtgeo_surf)
background_tasks.add_task(CACHE.set_RegularSurface, cache_key, xtgeo_surf)
#await CACHE.set_RegularSurface(cache_key, xtgeo_surf)

LOGGER.debug(f"Loaded surface, total time: {timer.elapsed_ms()}ms")

Expand Down

0 comments on commit f29104c

Please sign in to comment.