def cached_blog_entries(blog_fetcher=_blog_entries, key_prefix=KEY_PREFIX):
 blog_lock = CacheLock((key_prefix + LOCK_KEYNAME))
 if cache.get((key_prefix + FRESHNESS_KEYNAME)):
  entries = cache.get((key_prefix + DATA_KEYNAME))
  if entries:
   return entries
 try:
  with blog_lock:
   entries = blog_fetcher()
 except CacheLockInUse:
  return cache.get((key_prefix + DATA_KEYNAME))
 cache.set((key_prefix + FRESHNESS_KEYNAME), 'yay', BLOG_ENTRY_CACHE_TIMEOUT)
 cache.set((key_prefix + DATA_KEYNAME), entries, STALENESS_TOLERANCE)
 return entries

def cached_blog_entries ( blog_fetcher = _blog_entries , key_prefix = KEY_PREFIX ) : blog_lock = CacheLock ( ( key_prefix + LOCK_KEYNAME ) ) if cache . get ( ( key_prefix + FRESHNESS_KEYNAME ) ) : entries = cache . get ( ( key_prefix + DATA_KEYNAME ) ) if entries : return entries try : with blog_lock : entries = blog_fetcher ( ) except CacheLockInUse : return cache . get ( ( key_prefix + DATA_KEYNAME ) ) cache . set ( ( key_prefix + FRESHNESS_KEYNAME ) , 'yay' , BLOG_ENTRY_CACHE_TIMEOUT ) cache . set ( ( key_prefix + DATA_KEYNAME ) , entries , STALENESS_TOLERANCE ) return entries
return a cached copy of blog entries that weve fetched .