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();

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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