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

Handle both redis response codes on PTTL #45

Merged
merged 1 commit into from
Nov 7, 2018
Merged

Conversation

andrewhoff
Copy link
Contributor

@andrewhoff andrewhoff commented Nov 6, 2018

Hi! I've periodically come across cannot configure timeout on key errors being returned from this block of code, and I think I've narrowed it down to a race-condition in key presence when using .Get from multiple goroutines concurrently. It seems that in the odd case that that the ttl is set to -2 (key doesn't exist) trying to expire that key returns !ok which I think could be avoided by checking if ttl==-1 instead of ttl<0. This would help ensure that expire doesn't get called on a non-existant key. So far this has been working in my implementation but I'd like to know your thoughts @novln.

Thanks for taking the time to read this!

https://redis.io/commands/pttl

@andrewhoff andrewhoff changed the title Handle both response codes on PTTL Handle both redis response codes on PTTL Nov 6, 2018
@novln
Copy link
Contributor

novln commented Nov 7, 2018

Yep that make sense, thank you for your contribution 👍

@novln novln merged commit 3cab803 into ulule:master Nov 7, 2018
@andrewhoff
Copy link
Contributor Author

Thanks @novln!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants