Comments (4)
Hi @jodydonetti. Awesome! I think the new manual is great for new lib users to see the recommended approach with DI.
from fusioncache.
Ah, good points!
It's some time already that I wanted to sit down and take a better look at the DI setup part, for some of the reasons you pointed out and then some.
Give me some time to write them down here, so that we can discuss the best way to proceed 👍
from fusioncache.
Hi @adambajguz , some time has passed 😅 and now I'm getting back to my backlog.
Rationale
[...]
useDistributedCacheIfAvailable
allows to skip distributed cache setup during AddFusionCache call, so that it can be setup later using setupCacheAction. Thus, defered setup through setupCacheAction allows to e.g. resolve a IOptions that may store whether to use distributed caching or not. Unfortunately, backplane "auto" setup cannot be disabled through a parameter.
I'd like to explain my thought process here.
Since FusionCache uses any impl of the the standard IDistributedCache
interface as a 2nd level, what may happen is that one such impl is already registered in your app for other reasons, and you may not want to use a FusionCache 2nd layer only because you (or another component) have registered that somewhere at startup.
For example ASP.NET itself automatically register one in case it is needed by the cache tag helper, and even more strangely so it automatically registers a MemoryDistributedCache
, which is not actually distributed at all: that is the reason btw why I also included an ignoreMemoryDistributedCache
param that defaults to true
.
The logic here is that the default experience would be something like "if there is an impl of IDistributedCache
(except the fake one) use it" .
Backplane
Having said that, the backplane is a different thing altogether.
It requires an impl of a specific IFusionCacheBackplane
interface, and there can't possibly be one registered automatically or "by mistake": you have to register that explicitely via AddFusionCacheStackExchangeRedisBackplane
so there are no surprises there. If you don't want to use a backplane, don't call the registration method, it will not start automatically. And if you want to do that based on some config or logic, you can just put an if
around the backplane registration instead, and nothing else will be affected by that.
Now let's say you want to have the ability to have the backplane added to an existing FusionCache instance later on, at some point based on some logic or event: you simply have to not register it via AddFusionCacheStackExchangeRedisBackplane
and, when the time comes, you'll be able to just do this:
_cache.SetupBackplane(new RedisBackplane(...));
and that's all is needed.
So
Now, having said all of this in regard to the specific point about the backplane, I'm still open nonetheless about the more broad concept of having more customization available in the DI registration phase, so I'm thinking about expanding it.
Hope this helps.
If you can I'd like to know your opinions about this.
from fusioncache.
Hi @adambajguz , I've added a new doc specific about DI here: if you like please let me know what you think.
Thanks!
from fusioncache.
Related Issues (20)
- [FEATURE] Better detection of incoherent `CacheName`s options HOT 4
- [QUESTION] Can I use FusionCache only for getting data from a 2nd level (distributed) without InMemory part? HOT 5
- [FEATURE] 📢 Add `IgnoreIncomingBackplaneNotifications` options HOT 2
- [FEATURE] Improve nullable for GetOrSet with non-null factory HOT 8
- Explicitly tell the Factory that it failed HOT 9
- [FEATURE] Combination of eager refresh with distributed cache duration. HOT 5
- [FEATURE] Add a method for list all caches in IFusionCacheProvider (Ex: for dispose purposes) HOT 4
- Possibility of creation of a count variable in distributed cache HOT 2
- [FEATURE] Post factory executed event with possibility to change the cache settings before it be inserted in cache HOT 3
- Syncing different cloud instances HOT 4
- [BUG] Value is stored for longer than FailSafeMaxDuration HOT 7
- [BUG] AllowBackgroundDistributedCacheOperations serialization and cache operations seem to be happening in the foreground HOT 3
- best way to store FusionCacheEntryOptions in iConfiguration HOT 3
- Nullable `Size` option HOT 3
- [BUG] Deadlock caused by cancellation of eager refresh HOT 8
- [BUG] Slow Performance of FusionCache compared to Microsoft.Extensions.Caching.Memory.MemoryCache HOT 4
- [BUG] FailSafe max duration is somehow ignored HOT 7
- [FEATURE] Optimise dependencies by adding TFM HOT 9
- 💡 Add this project to awesome-italia-opensource HOT 2
- [BUG] Possible bug. FusionCache + EntityFramework (latest) on ASP NET Core 8 (.NET 8) HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fusioncache.