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

More granular timeouts #16

Open
Suor opened this issue Feb 26, 2015 · 9 comments
Open

More granular timeouts #16

Suor opened this issue Feb 26, 2015 · 9 comments

Comments

@Suor
Copy link

Suor commented Feb 26, 2015

Redis supports millisecond timeouts on SET with PX, but BLPOP understands only integer seconds. This is still achievable by using publish/subscribe with a bit more hustle.

@ionelmc
Copy link
Owner

ionelmc commented Feb 26, 2015

Do you need this feature for cacheops?

@Suor
Copy link
Author

Suor commented Feb 26, 2015

Yes. I plan to expose this timeout as user setting. It also makes sense to set it to same time as calculation will take, which is usually under second in web apps.

@ionelmc
Copy link
Owner

ionelmc commented Feb 26, 2015

Just to understand this correctly, I wonder - wouldn't that create a smaller dogpile effect if the database and management overhead (query serialization, deserialization and cache storage) takes more than 1 second?

If we use pubsub then all the clients would be woken up, even if they can't get the lock.

On the other hand, this slightly less efficient technique could be active only if the timeout is a fraction.

@Suor
Copy link
Author

Suor commented Feb 26, 2015 via email

@ionelmc
Copy link
Owner

ionelmc commented Feb 26, 2015

Now I'm not sure if you still want this feature. Should I take this as a "not for now"?

@Suor
Copy link
Author

Suor commented Feb 26, 2015 via email

@jhorman
Copy link

jhorman commented May 28, 2015

Sorry to hijack a thread for a question, but here goes. From what I understand, when Redis runs low on memory, it will randomly sample keys, and evict the ones with the shortest remaining ttl. That means that you cannot rely on your expire ttl to be accurate when churning the cache. That means under memory constraints, locks might disappear if using expires. It might be safer to not use redis expires, and maintain your own expirations.

Or, I have this all wrong.

@zoni
Copy link
Contributor

zoni commented Jul 30, 2015

@jhorman (and anyone else coming by this issue), what Redis does when running out of memory depends on the specific eviction policy you have configured.

For this use-case (distributed locking, especially with low-TTL keys), setting a noeviction policy might be wise.

@dimaqq
Copy link

dimaqq commented Sep 15, 2016

Please document noeviction requirement.

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

No branches or pull requests

5 participants