Skip to content

Instantly share code, notes, and snippets.

@tokikanno
Created September 27, 2019 12:25
Show Gist options
  • Select an option

  • Save tokikanno/5cb4bdafbee7959ea40455c79a166911 to your computer and use it in GitHub Desktop.

Select an option

Save tokikanno/5cb4bdafbee7959ea40455c79a166911 to your computer and use it in GitHub Desktop.
def cached_function():
result = cache.get(cache_key)
if result:
return result
result = heavy_generate_function()
cache.set(cache_key, result, expire_time)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment