Replies: 1 comment 4 replies
-
Hi @rjrudman and thanks for using FusionCache!
This is really strange, never heard of this. Also, what does it mean "The execution environment may be paused between invocations"? In which sense "paused"? What happens when it is "un-paused"? Do you have an example of what happen with singleton when pausing/unpausing? I'd like to know more, and if you can provide some links (blog posts, tutorials, etc) that would be great.
Agree, try to avoid this.
Again, agree: it feels "smelly", even though I would need to look more into the details of this approach.
I was about to suggest low memory duration + higher distributed duration, but first I'd like to understand more about singleton vs scoped with execution pause/unpause.
About named caches, I just released v1.2.0 which also contains support for keyed services 😉
Let me think about it, will let you know, but please give me some more info as said above. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to have the service lifetime configuration for
AddFusionCache
configurable? Currently it's hard-coded to be a singleton:We also can't easily create our own extension to do so, as the
FusionCacheBuilder
is internal.The reason we'd like this functionality is to be able to instantiate one
IMemoryCache
per scope - in particular, one per AWS lambda invocation. This is because:This means that the memory cache may become stale, and we cannot use the backplane to resolve this as the environment may be paused during an update (and additionally, we'd like to skip the backplane anyway to reduce overhead - it is acceptable to have items become stale during a single invocation). We also need to be mindful about memory usage, and the items in the cache between invocations probably do not overlap.
We have a few options at the moment, but none are ideal:
AddFusionCache
extension:services.AddScoped<IFusionCache>(sp => new FusionCache(new FusionCacheOptions { ... }))
. Though then we'd need to be sure to keep in sync with the extension method (ie callingAddOptions
,AddFusionCacheProvider
), as well as handling the named cachesIs this something that could be feasibly implemented? Is there another way to have an isolated
IMemoryCache
used for a particular scope?Beta Was this translation helpful? Give feedback.
All reactions