Skip to content

Commit

Permalink
Try caching again
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdp committed Nov 10, 2023
1 parent 096a308 commit caa4149
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
18 changes: 9 additions & 9 deletions backend/src/backend/primary/routers/surface/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ async def get_realization_surface_data(
) -> schemas.SurfaceData:
perf_metrics = PerfMetrics(response)

#user_cache: UserCache = get_user_cache(authenticated_user)
#cache_key = f"surface:{case_uuid}_{ensemble_name}_{realization_num}_{name}_{attribute}_{time_or_interval}"
user_cache: UserCache = get_user_cache(authenticated_user)
cache_key = f"surface:{case_uuid}_{ensemble_name}_{realization_num}_{name}_{attribute}_{time_or_interval}"

cached_xtgeo_surf = None
#cached_xtgeo_surf = await user_cache.get_RegularSurface(cache_key)
#cached_xtgeo_surf = await user_cache.get_Any(cache_key)
cached_xtgeo_surf = await user_cache.get_Any(cache_key)
#cached_xtgeo_surf = await user_cache.get_RegularSurface_HACK(cache_key)
#perf_metrics.record_lap(f"read-cache{'-hit' if cached_xtgeo_surf else '-miss'}")

Expand All @@ -88,12 +88,12 @@ async def get_realization_surface_data(
if not xtgeo_surf:
raise HTTPException(status_code=404, detail="Surface not found")

# if not cached_xtgeo_surf:
# #await user_cache.set_RegularSurface(cache_key, xtgeo_surf)
# await user_cache.set_Any(cache_key, xtgeo_surf)
# #await user_cache.set_RegularSurface_HACK(cache_key, xtgeo_surf)
# #background_tasks.add_task(user_cache.set_RegularSurface_HACK, cache_key, xtgeo_surf)
# perf_metrics.record_lap("write-cache")
if not cached_xtgeo_surf:
#await user_cache.set_RegularSurface(cache_key, xtgeo_surf)
await user_cache.set_Any(cache_key, xtgeo_surf)
#await user_cache.set_RegularSurface_HACK(cache_key, xtgeo_surf)
#background_tasks.add_task(user_cache.set_RegularSurface_HACK, cache_key, xtgeo_surf)
perf_metrics.record_lap("write-cache")

surf_data_response = converters.to_api_surface_data(xtgeo_surf)
perf_metrics.record_lap("convert")
Expand Down
7 changes: 2 additions & 5 deletions radixconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ spec:
ports:
- name: http
port: 8080
resources:
requests:
memory: 1Gi
cpu: 800m


- name: backend-primary
dockerFileName: backend.Dockerfile
ports:
Expand Down Expand Up @@ -79,6 +75,7 @@ spec:
ALLOW_EMPTY_PASSWORD: yes
REDIS_PORT_NUMBER: 6380
# https://redis.io/docs/management/config/#configuring-redis-as-a-cache
# maxmemory for redis must be aligned with component's requested memory, here 1gb vs 2gb
REDIS_EXTRA_FLAGS: --maxmemory 1gb --maxmemory-policy allkeys-lru --save '' --appendonly no --loglevel debug
resources:
requests:
Expand Down

0 comments on commit caa4149

Please sign in to comment.