Skip to content

Commit

Permalink
Redis migration to latest version. Adjust zadd to newer syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbres committed Oct 10, 2022
1 parent 3e2af08 commit ab229e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions api/redis_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self):
def _get_redis(self):
self.lock.acquire()
if not self.redis:
self.redis = redis.Redis(host=self.host, port=self.port, db=self.db)
self.redis = redis.Redis(host=self.host, port=self.port, db=self.db, decode_responses=True)
self.lock.release()
return self.redis

Expand Down Expand Up @@ -88,7 +88,7 @@ def inbox_create(self, id, ttl, response_mode):
pipe.multi()
pipe.set(key, json.dumps(val))
pipe.sadd(set_key, try_id)
pipe.zadd(exp_key, try_id, exp_time)
pipe.zadd(exp_key, {try_id: exp_time})
pipe.execute()
return try_id
except redis.WatchError:
Expand Down Expand Up @@ -149,7 +149,7 @@ def inbox_refresh(self, id, newttl=None):
exp_time = now + val['ttl']
pipe.multi()
pipe.set(key, json.dumps(val))
pipe.zadd(exp_key, id, exp_time)
pipe.zadd(exp_key, {id: exp_time})
pipe.execute()
break
except redis.WatchError:
Expand Down Expand Up @@ -442,7 +442,7 @@ def request_add_pending(self, inbox_id, item_id):
exp_time = now + 20
pipe.multi()
pipe.set(req_key, json.dumps([inbox_id, item_id]))
pipe.zadd(req_exp_key, req_id, exp_time)
pipe.zadd(req_exp_key, {req_id: exp_time})
pipe.execute()
break
except redis.WatchError:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Pygments==2.13.0
PyJWT==2.5.0
pyparsing==3.0.9
pytz==2022.2.1
redis==2.10.3
redis==4.3.4
requests==2.28.1
six==1.16.0
snowballstemmer==2.2.0
Expand Down

0 comments on commit ab229e5

Please sign in to comment.