def cache_result(func):
def cache_set(key, value):<EOL><INDENT>cache.set(key, value, AVATAR_CACHE_TIMEOUT)<EOL>return value<EOL><DEDENT>def cached_func(user, size):<EOL><INDENT>prefix = func.__name__<EOL>cached_funcs.add(prefix)<EOL>key = get_cache_key(user, size, prefix=prefix)<EOL>return cache.get(key) or cache_set(key, func(user, size))<EOL><DEDENT>return cached_func<EOL>
Decorator to cache the result of functions that take a ``user`` and a
``size`` value.