def cache_result(default_size=settings.AVATAR_DEFAULT_SIZE):
 if (not settings.AVATAR_CACHE_ENABLED):
  def decorator(func):
   return func
  return decorator
 def decorator(func):
  def cached_func(user, size=None):
   prefix = func.__name__
   cached_funcs.add(prefix)
   key = get_cache_key(user, (size or default_size), prefix=prefix)
   result = cache.get(key)
   if (result is None):
    result = func(user, (size or default_size))
    cache_set(key, result)
   return result
  return cached_func
 return decorator

def cache_result ( default_size = settings . AVATAR_DEFAULT_SIZE ) : if ( not settings . AVATAR_CACHE_ENABLED ) : def decorator ( func ) : return func return decorator def decorator ( func ) : def cached_func ( user , size = None ) : prefix = func . __name__ cached_funcs . add ( prefix ) key = get_cache_key ( user , ( size or default_size ) , prefix = prefix ) result = cache . get ( key ) if ( result is None ) : result = func ( user , ( size or default_size ) ) cache_set ( key , result ) return result return cached_func return decorator
decorator to cache the result of functions that take a user and a size value .