def local_cache(namespace, key, generator, regenerate_if_none=False):
 if (namespace not in local.cache):
  local.cache[namespace] = {}
 if (key not in local.cache[namespace]):
  local.cache[namespace][key] = generator()
 elif ((local.cache[namespace][key] == None) and regenerate_if_none):
  local.cache[namespace][key] = generator()
 return local.cache[namespace][key]

def local_cache ( namespace , key , generator , regenerate_if_none = False ) : if ( namespace not in local . cache ) : local . cache [ namespace ] = { } if ( key not in local . cache [ namespace ] ) : local . cache [ namespace ] [ key ] = generator ( ) elif ( ( local . cache [ namespace ] [ key ] == None ) and regenerate_if_none ) : local . cache [ namespace ] [ key ] = generator ( ) return local . cache [ namespace ] [ key ]
a key value store for caching within a request .