Comments (12)
Hi @giulianob , I'm looking into this right now.
I'd like to avoid releasing a new version in a rush, so if I can find a quick temporary workaround I'll tell you right away.
Will update you asap.
from fusioncache.
Yeah pre-release would be fine. Thanks!
from fusioncache.
Hi @giulianob and thanks for using FusionCache!
A couple of points.
I may add a FusionCacheEntryOption
to auto-dispose a value when evicted, so that you may have granular control per each cache entry. Of course as always you may then set this in the DefaultEntryOptions
once and it will be used as a default for all entries.
Sounds good?
What do you think should happen when a value is being set (either by calling a Set()
, GetOrSet()
or because of a remote notification from the backplane, etc) and there's an override? I'm not 100% sure IMemoryCache
always considers this an eviction even though here there's a Replaced
value (anyway I'll check and do some tests), so I would like to know if in this case you would also like to dispose, since the old value is being overwritten.
Ofcourse in that case I should also probably check for the fact that the new value is different from the old one, otherwise a piece of code like this:
var myDisposable = new MyDisposable();
cache.Set("foo", myDisposable);
cache.Set("foo", myDisposable);
would end up disposing the very object we are about to set.
Let me know what you think, thanks.
from fusioncache.
In the meantime I was also thinking about this: as we know a memory cache stores live object references, therefore when you get something from the cache you are using exactly the same instance.
This means that if you get something from the cache and then it gets disposed, you'll end up working on a disposed object, with all the problems this will create.
A practical example:
var myDisposable = new MyDisposable();
cache.Set("foo", myDisposable, TimeSpan.FromSeconds(2));
var foo = cache.GetOrDefault<MyDisposable>("foo");
// 2 SEC LATER...
if (foo is not null) {
// THIS WILL PROBABLY THROW AN ObjectDisposedException
foo.Whatever();
}
What do you think?
from fusioncache.
In my scenario, I am making sure to set the duration longer than the amount of time the object can be referenced (the request timeout in my case). You do need to be careful. I am storing objects that must be disposed to free up resources rather than waiting for GC to occur.
from fusioncache.
@jodydonetti Is there any workaround available to get the item being evicted in the callback?
from fusioncache.
I think I need to release a new version, there's no other way around it.
I'll try to release it tomorrow night.
Just to be sure: a pre-release version would be ok right?
from fusioncache.
Hi all, the v0.24.0-preview1 pre-release is out now on Nuget 🎉
NOTE: remember to check the "include prerelease" checkbox in your IDE to see it!
from fusioncache.
Ho @giulianob , did you have time to check this?
Thanks!
from fusioncache.
Yes, exactly what I needed. Thanks!
from fusioncache.
Awesome, thanks 🥳
Will close this when the non-preview next version will be release.
from fusioncache.
Hi all, the v0.24.0 release is out now on Nuget 🎉
It is a massive release with a lot of new features, optimizations and more, I suggest to check out the release notes.
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 5
- [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.