Replies: 2 comments 3 replies
-
|
Hi @rsalus , thanks for the very thorough issue. Short version: look at this item sitting in my FusionCache todo list for quite some time 😬 Longer version: just like with the So: no, there will be no need to go through the Thoughts? |
Beta Was this translation helpful? Give feedback.
-
|
That makes sense and would certainly be the most straightforward option for FusionCache. I have two main thoughts:
Beyond those two things, it really comes down to how API shape looks like. Naturally, I'd hope there would be support for low allocations; I'd want to avoid closures ( |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
It's no secret that the
IMemoryCacheinterface is rather limited. In the past few years, there have been rumblings of updating the implementation and even creating an entirely new one. Besides its counterintuitive design and lackluster performance characteristics, one major gap I've noticed with .NET's in-memory caching is the lack of a configurable cache replacement policy or admission policy.Ask
I'm aware that this is quite a broad topic, but would it be possible for FusionCache to offer support for configuring L1 caching strategies? It may be significantly out of scope for FusionCache to offer the implementation(s) for this directly, but there are existing caching primitives available (the excellent BitFaster library comes to mind).
As far as I'm aware, there are two "tricky" aspects to this:
IMemoryCache. This seems feasible but would require careful implementation, especially around handlingICacheEntry.Why
I think there is significant value in tailoring in-memory caching strategies for specific workloads. Some examples off the top of my mind:
Scenario 1: An application caches results from user searches or generates user-specific reports/views. Many of these items might be accessed only once ("one-hit wonders") and never needed again, while others might be revisited.
MemoryCacheLimitation:MemoryCachegenerally admits any item you.Set(). Caching large numbers of unique, single-use items can "pollute" the cache, filling it with data that offers little future value and causing more useful, frequently accessed items to be evicted prematurely.Scenario 2: An application caches data that is core to many requests but changes infrequently – think product categories, country lists, global configuration settings, user roles/permissions, etc. Some of this data might be extremely popular, while other parts are accessed less often.
MemoryCacheLimitation: Under memory pressure,MemoryCachemight evict a very popular (high frequency) butNormalpriority item if it hasn't been accessed very recently, especially if many less popularHighpriority items exist or were accessed more recently. Its recency bias (part of its internal heuristic) can work against keeping globally popular items.Would love to hear your thoughts @jodydonetti!
Beta Was this translation helpful? Give feedback.
All reactions