Skip to content

Commit

Permalink
Merge pull request #7 from leonardon473/wrapped-function-recalled
Browse files Browse the repository at this point in the history
Wrapped func is recalled when result is None.
  • Loading branch information
nezhar authored Dec 23, 2022
2 parents 6589bbe + 1f71252 commit f6b2acf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions django_request_cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ def wrapper(*args, **kwargs):

# cache found -> check if a result is already available for this function call
key = cache_calculate_key(fn.__name__, *args, **kwargs)
result = getattr(cache, key, None)

if not result:
try:
result = getattr(cache, key)
except AttributeError:
# no result available -> execute function
result = fn(*args, **kwargs)
setattr(cache, key, result)

return result
return wrapper

0 comments on commit f6b2acf

Please sign in to comment.