-
Notifications
You must be signed in to change notification settings - Fork 39
ConcurrentLru expire after access eviction policy #464
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
Conversation
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public ItemDestination RouteHot(LongTickCountLruItem<K, V> item) | ||
| { | ||
| if (this.ShouldDiscard(item)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a possible optimization here (which also applies to TLRu): all of the route methods call into ShouldDiscard, which evaluates the time most likely 3 times per cycle.
When warmed up, RouteHot is always called first (because we always try to dequeue from hot). During warm up, this may not happen.
If we change core to call route hot as a throw away call from warmup, we could eliminate some time calls in the normal case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RouteHot trick could also be applied to TrimExpired routine, which will also make many dupe time calls.
|
Builder doesn't request events - so AfterAccess is comparable to FastTLru.
|
Implement an expire after access eviction policy with a fixed time to live. This replicates the sliding window expiration provided by
MemoryCacheand the expireAfterAccess policy implemented in Caffeine:Summary of changes:
AfterAccessLongTicksPolicyitem policy, with different versions for .NET standard and .NET3/6, to use the fasterEnvironment.TickCount64where available.ConcurrentLruBuildernow supportsWithExpireAfterAccessConcurrentLruCorewithAfterAccessLongTicksPolicyWithExpireAfterAccessandWithExpireAfterWritethrows an exception.ExpireAfterAccessproperty. This is mapped to underlying cache policy viaConcurrentLruCore.CreatePolicy