diff --git a/lib/Singleton.js b/lib/Singleton.js index 08a72182..ec30c234 100644 --- a/lib/Singleton.js +++ b/lib/Singleton.js @@ -5,9 +5,12 @@ exports.get = function (key, opts, createCb, returnCb) { return createCb(returnCb); } if (map.hasOwnProperty(key)) { - if (map[key].t !== null && map[key].t <= Date.now()) { + if (opts && opts.save_check && typeof map[key].o.saved == "function" && !map[key].o.saved()) { + // if not saved, don't return it, fetch original from db + return createCb(returnCb); + } else if (map[key].t !== null && map[key].t <= Date.now()) { delete map[key]; - } else { + } else { return returnCb(map[key].o); } }