0

I'm not getting recent data when querying, and I believe it has to do with cache.

Probably, MongoDB's cache invalidation fails somewhere. I'd like to disable it completely and I don't care about performance.

Getting recent data using a query like this:

await Sessions.find({ ip: ip}).sort({ receive_time: -1 }).lean().limit(1).exec();
0

1 Answer 1

2

Mongo database service doesn't search for answers to your query in only the cache. It searches in the memory and if it doesn't find your answers, it has to go into the storage.

You can try the query below, and you will see the last data on your table.

db.zips.find().sort({ "_id": -1 }).limit(10)

Check out your data and your query, probably your condition is wrong.

1
  • Well, I used something like when I build the app initially but it also had same issue.
    – sqlbie
    Oct 23, 2020 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.