Browse Source

hiding queues inside CallbackFiller

feature/specify-what-to-cache
Bryan Donovan 10 years ago
parent
commit
1e8f67821e
  1. 9
      lib/caching.js
  2. 12
      lib/callback_filler.js
  3. 9
      lib/multi_caching.js

9
lib/caching.js

@ -44,12 +44,9 @@ var caching = function(args) {
options = undefined;
}
if (callbackFiller.queues[key]) {
callbackFiller.queues[key].push({cb: cb, domain: process.domain});
return;
}
callbackFiller.queues[key] = [{cb: cb, domain: process.domain}];
var hasKey = callbackFiller.has(key);
callbackFiller.add(key, {cb: cb, domain: process.domain});
if (hasKey) { return; }
self.store.get(key, options, function(err, result) {
if (err && (!self.ignoreCacheErrors)) {

12
lib/callback_filler.js

@ -16,4 +16,16 @@ CallbackFiller.prototype.fill = function(key, err, data) {
});
};
CallbackFiller.prototype.has = function(key) {
return this.queues[key];
};
CallbackFiller.prototype.add = function(key, funcObj) {
if (this.queues[key]) {
this.queues[key].push(funcObj);
} else {
this.queues[key] = [funcObj];
}
};
module.exports = CallbackFiller;

9
lib/multi_caching.js

@ -96,12 +96,9 @@ var multiCaching = function(caches) {
options = undefined;
}
if (callbackFiller.queues[key]) {
callbackFiller.queues[key].push({cb: cb, domain: process.domain});
return;
}
callbackFiller.queues[key] = [{cb: cb, domain: process.domain}];
var hasKey = callbackFiller.has(key);
callbackFiller.add(key, {cb: cb, domain: process.domain});
if (hasKey) { return; }
getFromHighestPriorityCache(key, function(err, result, index) {
if (err) {

Loading…
Cancel
Save