Redis ttl and pttl returns None when ttl value is 0
See original GitHub issuer=redis.Redis()
print r.set("foo", "bar")
print r.expire("foo", 1)
time.sleep(0.5)
print r.ttl("foo")
print r.get("foo")
prints
True
True
None
bar
but ttl should return 0 in this case, expire is set
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Redis ttl and pttl returns None when ttl value is 0 #693 - GitHub
When I try to check the ttl on a key that does not have an expire set using this library, I get None...
Read more >TTL - Redis
The command returns -1 if the key exists but has no associated expire. See also the PTTL command that returns the same information...
Read more >Redis key TTL becoming -1 even when expiry is being set in a ...
The command returns -1 if the key exists but has no associated expire. How is the TTL becoming -1 when we are setting...
Read more >Redis TTL | How to Improve Key Expiration in Redis? - eduCBA
Redis TTL command is used for calculating the remaining time and retrieving the time expired seconds. The timeout session's integer value expired the...
Read more >RedisKeyAsyncCommands (lettuce 4.5.0.Final API)
Returns : Long integer-reply TTL in milliseconds, or a negative value in order to signal an error (see the description above).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

it works correctly if you use
r = redis.StrictRedis()This was resolved as part of redis-py 3.0. Closing this.