Skip to content

Commit

Permalink
Merge pull request #1375 from niphlod/fix/1355
Browse files Browse the repository at this point in the history
fixes #1355
  • Loading branch information
mdipierro committed Jul 1, 2016
2 parents 46d02a3 + a96f137 commit 5a5c2b5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gluon/contrib/redis_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def RedisCache(redis_conn=None, debug=False, with_lock=False, fail_gracefully=Fa
try:
instance_name = 'redis_instance_' + current.request.application
if not hasattr(RedisCache, instance_name):
setattr(RedisCache, instance_name,
setattr(RedisCache, instance_name,
RedisClient(redis_conn=redis_conn, debug=debug,
with_lock=with_lock, fail_gracefully=fail_gracefully))
return getattr(RedisCache, instance_name)
Expand Down Expand Up @@ -137,6 +137,10 @@ def __call__(self, key, f, time_expire=300, with_lock=None):
value = None
ttl = 0
try:
if f is None:
# delete and never look back
self.r_server.delete(newKey)
return None
# is there a value
obj = self.r_server.get(newKey)
# what's its ttl
Expand All @@ -149,9 +153,6 @@ def __call__(self, key, f, time_expire=300, with_lock=None):
if self.debug:
self.r_server.incr('web2py_cache_statistics:hit_total')
value = pickle.loads(obj)
elif f is None:
# delete and never look back
self.r_server.delete(newKey)
else:
# naive distributed locking
if with_lock:
Expand Down

0 comments on commit 5a5c2b5

Please sign in to comment.