Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTL returns -2 (not found) for empty streams #313

Closed
Eugeny opened this issue Jun 26, 2024 · 6 comments
Closed

TTL returns -2 (not found) for empty streams #313

Eugeny opened this issue Jun 26, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@Eugeny
Copy link

Eugeny commented Jun 26, 2024

STR:

fake_redis.xadd(self.stream_name, {'x': 1})
fake_redis.expire(self.stream_name, 60 * 60 * 24 * 365 * 99)
assert fake_redis.keys(self.stream_name) 
fake_redis.ttl(self.stream_name) # is -2

Python 3.10
redis-py==4.5.4
fakeredis==2.23.2

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@Eugeny Eugeny added the bug Something isn't working label Jun 26, 2024
@Eugeny Eugeny changed the title TTL returns -2 (not found) for streams TTL returns -2 (not found) for empty streams Jun 26, 2024
@Eugeny
Copy link
Author

Eugeny commented Jun 26, 2024

Upon further investigation this is due to if (not key...) return in _expireat, whose __bool__ then checks for bool(self._value) which is False because XStream.__len__ is 0

@cunla
Copy link
Owner

cunla commented Jun 26, 2024

Thanks for reporting this. Do you want to work on a fix and submit a PR (since you already did the hard part)?

Otherwise, I will work on it this weekend;

@Eugeny
Copy link
Author

Eugeny commented Jun 26, 2024

I'm not actually sure what the purpose of the if not key check in _expireat is so I would prefer not to risk breaking anything by not knowing the library, I literally just started using it today :D

@cunla
Copy link
Owner

cunla commented Jun 26, 2024

No prob, I'll have a look at it later this week.
Thanks again for reporting

@cunla
Copy link
Owner

cunla commented Jun 28, 2024

fixed

@cunla cunla closed this as completed Jun 28, 2024
@Eugeny
Copy link
Author

Eugeny commented Jun 29, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants