Weighted cache entries with size limit #239
Replies: 2 comments 2 replies
-
What are you trying to achieve? To which part of .NEXT API the question belongs to? The lack of the context might lead to incorrect answer from my side. Anyway, I can try. The following code is not thread safe: total = Interlocked.Increment(x.Size); while(total > limit) cache.Trim(1); Assuming that
Thread 2 removes 2 items, thread 1 removes 1 item. As a result, the cache removes 3 items instead of 2. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Done in 5.19.0: https://dotnet.github.io/dotNext/api/DotNext.Runtime.Caching.RandomAccessCache-3.html |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i.e. if we know or approx the memory usage of each entry in Mb and want to bound the cache to X Mb.
If we picked a suitable N for the capacity bound and did this psuedocode:
any thoughts on stability/performance? I've been asking this everywhere because I can't find an implementation in .NET!
Beta Was this translation helpful? Give feedback.
All reactions