javascript - No update in the mongoose-cache after change in the collection -


i have mean stack based application , recently, trying implement caching mechanism caching query results. implemented mongoose-cache.

mongoose-cache configuration

require('mongoose-cache').install(mongoose, {max: 150, maxage:1000*60*10}); 

i have 2 document in sample collection

{name:'dale', dep:2}, {name:'john', dep:4}  

i run query mongoose-cache enabled , maxage 10 minutes.

sample.find().cache().exec(function (err, doc) {         // returns 2 document     });  

next, inserted 1 more document {name:'rasig', dep:4} , execute same query

sample.find().cache().exec(function (err, doc) {         // returns 2 document instead of 3     });    

i executed same query twice within 10 minutes, though there change in collection, got previous result. there way drop cached result once there change in collection. if not, can suggest else implement same.

i author of new mongoose module called monc

using monc quite easy clean or purge whole cache or the associated query objects simple using:

sample.find().clean().cache().exec(function (err, doc) {});   

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -