Skip to content

Commit

Permalink
Update redis.py
Browse files Browse the repository at this point in the history
  • Loading branch information
崔庆才丨静觅 committed Mar 7, 2020
1 parent 457c08d commit 4bca2d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions proxypool/storages/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def add(self, proxy: Proxy, score=PROXY_SCORE_INIT) -> int:
return
if not self.exists(proxy):
if IS_REDIS_VERSION_2:
return self.db.zadd(REDIS_KEY, score, proxy)
return self.db.zadd(REDIS_KEY, {proxy: score})
return self.db.zadd(REDIS_KEY, score, proxy.string())
return self.db.zadd(REDIS_KEY, {proxy.string(): score})

def random(self) -> Proxy:
"""
Expand Down Expand Up @@ -77,7 +77,7 @@ def decrease(self, proxy: Proxy) -> int:
# otherwise delete proxy
else:
logger.info(f'{proxy.string()} current score {score}, remove')
return self.db.zrem(REDIS_KEY, proxy)
return self.db.zrem(REDIS_KEY, proxy.string())

def exists(self, proxy: Proxy) -> bool:
"""
Expand Down

0 comments on commit 4bca2d6

Please sign in to comment.