Skip to content

Commit

Permalink
Merge pull request #64 from hnimminh/fix/#62
Browse files Browse the repository at this point in the history
#62 accept ttl of -1 from redis-py 3.x
  • Loading branch information
p authored Apr 15, 2021
2 parents 7585497 + 3fa213e commit d5affcb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions redisdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@ def __init__(self, *args, **kwargs):
def pttl_or_ttl(self, key):
if self.have_pttl:
pttl = self.pttl(key)
if pttl is None:
if pttl is None or pttl == -1:
return None
else:
return float(pttl) / 1000
else:
return self.ttl(key)
ttl = self.ttl(key)
if ttl is None or ttl == -1:
return None
else:
return ttl


def pttl_or_ttl_pipeline(self, p, key):
if self.have_pttl:
Expand All @@ -69,7 +74,7 @@ def pttl_or_ttl_pipeline(self, p, key):
return p.ttl(key)

def decode_pttl_or_ttl_pipeline_value(self, value):
if value is None:
if value is None or value == -1:
return None
if self.have_pttl:
return float(value) / 1000
Expand Down

0 comments on commit d5affcb

Please sign in to comment.