Code Monkey home page Code Monkey logo

Comments (10)

angularsen avatar angularsen commented on June 10, 2024 1

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.

jodydonetti avatar jodydonetti commented on June 10, 2024

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.

angularsen avatar angularsen commented on June 10, 2024

Great! Thanks for the speedy response. No rush on my end, have a great holiday!

from fusioncache.

jodydonetti avatar jodydonetti commented on June 10, 2024

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.

jodydonetti avatar jodydonetti commented on June 10, 2024

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.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.