possible fix for pubsub

This commit is contained in:
Barış Soner Uşaklı
2018-01-22 16:41:22 -05:00
parent 33a8cb947e
commit 8a6345ded7
6 changed files with 34 additions and 40 deletions

View File

@@ -1,5 +1,7 @@
'use strict';
var pubsub = require('../../pubsub');
module.exports = function (db, module) {
var helpers = module.helpers.mongo;
@@ -16,6 +18,25 @@ module.exports = function (db, module) {
cache.hits = 0;
module.objectCache = cache;
pubsub.on('mongo:hash:cache:del', function (key) {
cache.del(key);
});
pubsub.on('mongo:hash:cache:reset', function () {
cache.reset();
});
module.delObjectCache = function (key) {
pubsub.publish('mongo:hash:cache:del', key);
cache.del(key);
};
module.resetObjectCache = function () {
pubsub.publish('mongo:hash:cache:reset');
cache.reset();
};
module.setObject = function (key, data, callback) {
callback = callback || helpers.noop;
if (!key || !data) {