Skip to content

Commit

Permalink
Fix cache and limit
Browse files Browse the repository at this point in the history
  • Loading branch information
adammcgrath committed Sep 2, 2014
1 parent 686506d commit 15dab74
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def get(self):
if not q and not id:
return webapp2.Response('')

memcached = memcache.get(q)
cache_key = '%s-%s' % (q, limit) if q else id

memcached = memcache.get(cache_key)
if memcached and not debug:
if add_callback:
memcached = '%s(%s)' % (callback, memcached)
Expand All @@ -106,7 +108,7 @@ def get(self):
response = json.dumps(doc_to_dict(result), indent=indent)

if not debug:
memcache.set(q or id, response)
memcache.set(cache_key, response)

if add_callback:
response = '%s(%s)' % (callback, response)
Expand Down

0 comments on commit 15dab74

Please sign in to comment.