Cache only if data exists in database
rayburks opened this issue · 1 comments
rayburks commented
return mongoose.Query.prototype._exec.call(self, function(err, docs) {
if (err) return callback(err);
if(docs != null) {
var str = JSON.stringify(docs);
redisClient.setex(key, cacheOptions.expires, str);
}
return callback(null, docs);
});
If a database call returns null, the value null will be cached. I would expect not to cache a null value.
The callback return null, thats fine.
What do you think?
Regards Ray