News for hackers. Stuff that matters.
Re:Ask HN: What are some cool but obscure data structures yo... by zbentley on Friday July 22, 2022 @10:29AM (#32192202)
Yep, I've been bitten by exactly this failure mode.

You have to invalidate/bust the cache when a failure is returned (which is racy, but since cache busting is on the sad path it's a fine place to protect with a plain ol' mutex, assuming you even have real parallelism/preemption in the mix).

Alternatively you can cache promises to functions that will never return failure and will instead internally retry until they succeed. This approach generalizes less well to arbitrary promises, but is more friendly to implementing the custom back off/retry scheme of your choice.

There are no comments on this comment yet.