Skip to content

Commit

Permalink
fix: get_or_set_cache - Use Falsy cached values except None
Browse files Browse the repository at this point in the history
If `is_frappe_db` returned False, the value was cached but always re-ran
the function anyway making repeated unnecessary Database connections and
Error Logs to be created on execution of each query.
  • Loading branch information
gavindsouza committed Mar 25, 2024
1 parent 22676b0 commit 33d07ac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion insights/cache_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def make_digest(*args):
def get_or_set_cache(key, func, force=False, expiry=EXPIRY):
key = f"insights|{key}"
cached_value = frappe.cache().get_value(key)
if cached_value and not force:
if cached_value is not None and not force:
return cached_value

value = func()
Expand Down

0 comments on commit 33d07ac

Please sign in to comment.