Is there any way to disable MongoDB's cache? 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({ &quot;_id&quot;: -1 }).limit(10)

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