question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redis ttl and pttl returns None when ttl value is 0

See original GitHub issue
r=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:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jkasarheroucommented, Mar 16, 2016

it works correctly if you use r = redis.StrictRedis()

0reactions
andymccurdycommented, Jun 3, 2019

This was resolved as part of redis-py 3.0. Closing this.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found