Weighted cache entries with size limit #239
Unanswered
dave-yotta
asked this question in
Q&A
Replies: 1 comment 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
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