diff --git a/pillar/web/utils/caching.py b/pillar/web/utils/caching.py index 749f3154..92e055fd 100644 --- a/pillar/web/utils/caching.py +++ b/pillar/web/utils/caching.py @@ -1,3 +1,4 @@ +import collections import functools from flask import g @@ -13,13 +14,13 @@ def cache_for_request(): @functools.wraps(func) def wrapper(*args, **kwargs): if not hasattr(g, 'request_level_cache'): - g.request_level_cache = {} + g.request_level_cache = collections.defaultdict(dict) try: - return g.request_level_cache[args] + return g.request_level_cache[func][args] except KeyError: val = func(*args, **kwargs) - g.request_level_cache[args] = val + g.request_level_cache[func][args] = val return val return wrapper return decorator