Skip to content

Commit a3b6fac

Browse files
authored
Merge pull request shiyanlou#9 from zkqiang/master
Update cache.py
2 parents 6d3bed1 + 59ab6b3 commit a3b6fac

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

17-redis-cache-decorator/cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def cache(self, timeout=0):
1111
def decorator(f):
1212
@wraps(f)
1313
def wrapped(*args, **kwargs):
14-
if timeout == 0:
14+
if timeout <= 0:
1515
return f(*args, **kwargs)
1616
key = f.__name__
1717
raw = self._redis.get(key)
@@ -20,7 +20,7 @@ def wrapped(*args, **kwargs):
2020
self._redis.setex(key, timeout, json.dumps(value))
2121
return value
2222
else:
23-
return json.loads(raw)
23+
return json.loads(raw.decode())
2424
return wrapped
2525
return decorator
2626

0 commit comments

Comments
 (0)