Skip to content

Commit

Permalink
Update cache handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gislawill committed Nov 23, 2024
1 parent 9f04de9 commit 3222328
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api/app/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def cache_geojson(
geojson: GeoJSON, prefix: str, cache_key: str | None = None
) -> FilePath:
"""
Locally store geojson needed for a request.
Locally cache geojson for future use.
Args:
geojson (GeoJSON): The GeoJSON object to be cached.
Expand All @@ -116,10 +116,12 @@ def cache_geojson(
"""
json_string = json.dumps(geojson)

# If cache_key is provided, use it to generate the cache file path.
# Otherwise, use the JSON string of the geojson.
cache_filepath = _get_cached_filepath(
prefix=prefix,
cache_key=cache_key,
data=json_string,
cache_key=cache_key if cache_key else None,
data=json_string if not cache_key else None,
extension="json",
)

Expand Down

0 comments on commit 3222328

Please sign in to comment.