Comments (3)
Pinging @JoeShook because of course 😄
from fusioncache.
The plugins subsystem has been released with v0.1.5 🎉
from fusioncache.
I just published a new branch with the plugins subsystem here.
How to create a plugin
Write a class that implements the IFusionCachePlugin
interface, basically just the Start
and Stop
methods, like this.
Of course it can also accept its own set of options, typically modelled via IOptions<MyPluginType>
and friends.
How to use a plugin via DI
Register your plugin type in the DI container (better before registering FusionCache itself) to respond to the IFusionCachePlugin
service as a singleton, like here: when a FusionCache instance will be requested, all plugin types registered will be auto-discovered, added (and started) automatically.
Of course you can also define your own custom ext method (like this one) to be a better .NET citizen.
Example:
[...]
services.AddSingleton<IFusionCachePlugin, MyPlugin>();
services.AddFusionCache();
[...]
or with a custom ext method + custom options:
[...]
services.AddMyFusionCachePlugin(options => {
options.Whatever = 42;
});
services.AddFusionCache();
[...]
How to use a plugin without DI
Just create an instance of your plugin and pass it to the cache.AddPlugin
method, like here.
Remember that, in case the Start
method of your plugin throws and exception, an InvalidOperationException
would also be thrown by the AddPlugin
method itself (with the original exception as the inner one).
Removing a plugin
If you need continue using a FusionCache instance but want to remove a plugin you've previously added, you can call the cache.RemovePlugin
method: it will automatically call the Stop
method of the plugin and then remove it.
If instead you just want to clean things up "at the end" (and you should do it), you don't have to do anything because when the FusionCache
instance will be disposed, all added plugins will be stopped and removed automatically.
Opinions?
Anything would be appreciated, thanks!
from fusioncache.
Related Issues (20)
- [FEATURE] 🪞 Remove all usage of reflection HOT 6
- [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
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.