Skip to content

Instantly share code, notes, and snippets.

@fjorgemota
Last active January 15, 2016 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjorgemota/9c4cfc406f14de1e7412 to your computer and use it in GitHub Desktop.
Save fjorgemota/9c4cfc406f14de1e7412 to your computer and use it in GitHub Desktop.
def get_foo(foo_id):
foo = memcached.get("foo:%d" % foo_id)
if foo is not None:
return foo
foo = fetch_foo_from_database(foo_id)
memcached.set("foo:%d"% foo_id, foo)
return foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment