From 378a696bfe1fc23b784a91c06ba720535efb0489 Mon Sep 17 00:00:00 2001 From: Loren McGinnis Date: Sun, 12 Jan 2014 22:36:46 -0700 Subject: [PATCH] related to issue 1708 - bugfix to allow no expiration for gae_memcache When gae_memcache passed expiration time to memcache Client (see commit 59290534bc2faad501ba13c495aeb051d619314), logic is no longer needed to calculate time delta, since memcache handles that for us. Also, time_expire=0 was expiring values immediately, instead of the documented behavior where 0 signified no expiration. Kept timestamp in value for backwards compatibility (is this necessary since cached data is transient?) --- gluon/contrib/gae_memcache.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gluon/contrib/gae_memcache.py b/gluon/contrib/gae_memcache.py index 07e5ed0d..4f110212 100644 --- a/gluon/contrib/gae_memcache.py +++ b/gluon/contrib/gae_memcache.py @@ -27,15 +27,11 @@ class MemcacheClient(object): time_expire=300, ): key = '%s/%s' % (self.request.application, key) - dt = time_expire value = None obj = self.client.get(key) - if obj and (dt is None or obj[0] > time.time() - dt): + if obj: value = obj[1] - elif f is None: - if obj: - self.client.delete(key) - else: + elif f is not None: value = f() self.client.set(key, (time.time(), value), time=time_expire) return value