From 15dab7483952448b0f153851bbe9c11ba154a72c Mon Sep 17 00:00:00 2001 From: adammcgrath Date: Tue, 2 Sep 2014 20:36:50 +0100 Subject: [PATCH] Fix cache and limit --- src/api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api.py b/src/api.py index 8e9b6c2..74229e2 100644 --- a/src/api.py +++ b/src/api.py @@ -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) @@ -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)