Skip to content

Commit

Permalink
fix(Fish Species): use shared cache
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Apr 22, 2024
1 parent 6e1fd3d commit c9fca77
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ def get_fish_species_data(id: str = None) -> List[Dict]:
# We do not cache ID since it's uniqueness makes the API performant
return query_fish_species_data(id)

cache_exists = frappe.cache().hexists("fish_species_data", "all")
cache_exists = frappe.cache().hexists("fish_species_data", "all", shared=True)
if not cache_exists:
build_fish_species_cache()

return frappe.cache().hget("fish_species_data", "all")
return frappe.cache().hget("fish_species_data", "all", shared=True)


def build_fish_species_cache():
"""Rebuild entire fish species data and set in cache."""
frappe.cache().hset("fish_species_data", "all", query_fish_species_data())
frappe.cache().hset("fish_species_data", "all", query_fish_species_data(), shared=True)


def query_fish_species_data(id: str = None) -> List[Dict]:
Expand Down

0 comments on commit c9fca77

Please sign in to comment.