Comments (10)
Oh yeah, you are absolutely right about the two mistakes in the test code. I just threw it together real quick and the results matched what I saw in production code so I thought I got it right 😓😄
What you say about Get vs GetOrSet makes sense to me, we rarely use Get-path and I guess most other people also use it less frequently, which could explain why it took time to discover.
No good reason to not use MemoryDistributedCached, I could not think of any ready to go implementation in the heat of the moment so I just wrote my own for this piece of test code.
Thanks for the swift investigation and pointing out the mistakes, much appreciated 🙇 Will give the new version a go soon.
from fusioncache.
Perfect, will give it a go soon when I'm done wrapping up another small project.
from fusioncache.
It took me a while to get back to this, but I've tried v0.26 and this fix seems to work. Thanks!
from fusioncache.
Hi @angularsen the behavior should be the one you expected, so it seems like you hit a bug: maybe it's because of one of the changes I've made recently, but it's strange that the tests didn't catch that.
I'll be able to take a look at that after Christmas, will let you know.
Thanks for pointing that out!
from fusioncache.
Great! Thanks for the speedy response. No rush on my end, have a great holiday!
from fusioncache.
Hi @angularsen , upon further inspection it seems like we were both kinda right 😅
Basically in the "get or set" code path the check was correct, whereas in the "get only" code path (eg: TryGet
/GetOrDefault
) the check was not correct.
I tried to keep them as "aligned" as possible, but this escaped my efforts.
Now it's fixed in the new branch, and with the next release will be fixed.
Thanks for reporting it!
from fusioncache.
While we are here, a couple of notes.
First is a curiosity: why did you create a custom IDistributedCache
implementation that works only in memory, instead of using the existing one MemoryDistributedCache
? I was wondering if you had a particular reason.
Also, watch out for a couple of things in this line:
fakeDistributedCache.GetAsync(cacheKey).Should().NotBeNull("it should now be stored in distributed cache");
First, since you are calling the async version (fakeDistributedCache.GetAsync(cacheKey)
) and you are not using the await
keyword, what you are in fact testing is the returned Task<T>
which will always be non null
, and not the returned cached value itself.
Second, I see you are using the same cacheKey
to directly access the distributed cache, and typically the cache key is modified when talking to that (read here for more) so in theory it would always fail.
Hope this helps.
from fusioncache.
Hi @angularsen , I just released v0.25.0-preview1 🎉
This version includes the fix related to this issue, so if you can give it a try it would be great, thanks!
from fusioncache.
Hi @angularsen , I just release v0.25.0 🥳
from fusioncache.
from fusioncache.
Related Issues (20)
- 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
- [BUG] Possible bug. FusionCache + EntityFramework (latest) on ASP NET Core 8 (.NET 8) HOT 16
- [FEATURE] 🔺 Add .NET Aspire support HOT 3
- [FEATURE] 🔑 Add DI Keyed Services support HOT 18
- [FEATURE] Fall back Defaults for adaptive caching HOT 4
- [FEATURE] How about add compress support for large entries in distributed cache ? HOT 3
- [FEATURE] Utilize Microsoft.IO.RecyclableMemoryStream in flavor of creating new MemoryStream instances when serializing HOT 12
- [FEATURE] ⚡ Add `PreferSyncSerialization` option HOT 3
- [FEATURE] Allow the factory to determine the cache duration? HOT 4
- [BUG] 🔭 Better OpenTelemetry traces for incoming backplane notifications HOT 2
- [QUESTION] best way to do unit testing of code using fusion cache HOT 4
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.