|
|
|
|
|
by NovaX
2684 days ago
|
|
Yes, that would be fun. :) For fixed expiration (e.g. 5 min TTL), I use time-bounded LRU queues. Then if the head item has not expired, its successors have not either. If it has, it is merely a poll. For custom expiration (varies per-entry), I use a hierarchical timer wheel. This replaces sorting with hashing, with an amortized O(1) cost. For refresh, that's when I do it on access since its being used. I keep a refresh timestamp and an expiration timestamp, so that a refresh can occur while the data is valid but aging, but a blocking load is required when its too stale (expired). You might enjoy this slide deck of the ideas that I use:
https://docs.google.com/presentation/d/1NlDxyXsUG1qlVHMl4vsU... |
|