Skip to content

Instantly share code, notes, and snippets.

@tav
Created June 19, 2014 15:36
Show Gist options
  • Save tav/2834810b723f8ba86e83 to your computer and use it in GitHub Desktop.
Save tav/2834810b723f8ba86e83 to your computer and use it in GitHub Desktop.
from sentinel import handle, Timeout
@handle(public=True)
def location_find(ctx, place):
cache_key = 'location.find|%s' % place
try:
area = ctx.cache.get(cache_key, deadline=20)
except Timeout:
area = None
if not area:
area = "%s-%s" % (place, place)
ctx.cache.set(cache_key, area)
return area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment