mcollina / async-cache-dedupe

Async cache with dedupe support
MIT License
640 stars 40 forks source link

Got data hits two times in a roll from cache but returned different results #44

Closed yidongw closed 1 year ago

yidongw commented 1 year ago

I'm logging data with onHit.

I saw onHit being called with keyA and the result was dataA, sometime later I saw onHit being called again with keyA, but with result dataB.

I also was logging the storage set function and saw it is not being called in between the above two onHits.

dataA looks correct, but in order to get dataB, I have to add an extra query param which I didn't do in my codebase.

There are two problems here.

  1. dataB came out of nowhere. The first time saw it was when it came from the cache. You have to get the data from the database first before it can be stored in the cache, but there is nothing I can find that shows dataB is from the database query.
  2. dataB assigned itself to keyA out of nowhere. I couldn't track how it is being done.

How is this possible? How can I debug it to find where is the problem?

I'm using memory as cache, but I'm going to try redis and see if that solves the problem

EDIT: This problem doesn't happen in redis

mcollina commented 1 year ago

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

simone-sanfratello commented 1 year ago

Any update?

simone-sanfratello commented 1 year ago

Close due to inactivity