Coder Social home page Coder Social logo

Comments (5)

Turnerj avatar Turnerj commented on June 23, 2024

Hey @Miggleness - thanks for raising this! Looks like this is caused by 67deced where I was trying to work around a race condition. Will try and work out the best course of action to fix it without re-introducing that race condition.

from cachetower.

Miggleness avatar Miggleness commented on June 23, 2024

I could raise a PR too if you don't already have a fix ready

from cachetower.

Turnerj avatar Turnerj commented on June 23, 2024

Thanks for the offer! I'd normally accept it but I've already dug a bit into it now and have a fix mostly written.

var previousEntry = await GetAsync<T>(cacheKey);
if (previousEntry != default && noExistingValueAvailable && previousEntry.Expiry < DateTimeProvider.Now)
{

The code here is to always return an existing value if it originally thought there was no value (to satisfy the race condition). What it does with previousEntry.Expiry < DateTimeProvider.Now though implies that logic will also apply for expired entries - it should not be a < but a >= to imply returning only non-expired entries.

Can't believe I missed that when I wrote it!

While the fix can be as simple as switching the sign, I'm also looking into whether I switch out the boolean noExistingValueAvailable for an enum about the status of the entry (stale, expired, miss) as it might make the surrounding code more obvious too.

from cachetower.

Miggleness avatar Miggleness commented on June 23, 2024

cool. i was thinking along the same lines. im not sure sure about the locking part when refreshing

update: i get it now why. might be worth splitting RefreshValueAsync for each of those paths you mentioned.

from cachetower.

Turnerj avatar Turnerj commented on June 23, 2024

Thanks again @Miggleness for raising this and providing a simple drop-in test case for the bug - little things like that make my life a lot easier! I've just released 0.11.6 which includes the fix for this bug.

from cachetower.

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.