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

Expiring keys #1119

Closed
olanod opened this issue Jul 9, 2020 · 1 comment
Closed

Expiring keys #1119

olanod opened this issue Jul 9, 2020 · 1 comment
Labels

Comments

@olanod
Copy link

olanod commented Jul 9, 2020

Anyone building caches or a similar stores where it makes sense to add a time to live to the entries would benefit from this. Also a way to refresh the expiration would be nice if one wants to delete things that have been inactive for a determined amount of time.

@olanod olanod added the feature label Jul 9, 2020
@spacejam
Copy link
Owner

spacejam commented Jul 15, 2020

This is one of the more common feature requests that I don't believe is something that should be included in the core of sled itself.

The reason is that it adds significant space and compute overhead. Even if it's just one extra byte for a non-present expiration when every key is stored on disk, that could still be quite a significant cost at higher scales. When keys are known to be temporary, the effort to evict them can be pretty expensive. Only a small subset of use cases benefit from expiring keys, and I feel it's more appropriate to implement this as a layer on top of sled by adding your own optional timers as a prefix or suffix to your values. You can use IVec::subslice to avoid copying the rest to a new vec or something for use in your application.

When I managed large numbers of redis instances, key expiration was a constant source of pain. It seems like something that they are still twiddling with today. https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/improving-key-expiration-in-redis.html (still not merged into main branch)

I think I do need to add a "features we do not support" section though that explains this in a more visible place.

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

No branches or pull requests

2 participants