Browse Source

allow calling memory store get() without callback

feature/nested-cache-fetch-fix
Bryan Donovan 11 years ago
parent
commit
03c00b2d70
  1. 11
      lib/stores/memory.js
  2. 9
      test/caching.unit.js

11
lib/stores/memory.js

@ -20,9 +20,14 @@ var memory_store = function (args) {
}; };
self.get = function (key, cb) { self.get = function (key, cb) {
process.nextTick(function () { var value = lru_cache.get(key);
cb(null, lru_cache.get(key)); if (cb) {
}); process.nextTick(function () {
cb(null, value);
});
} else {
return value;
}
}; };
self.del = function (key, cb) { self.del = function (key, cb) {

9
test/caching.unit.js

@ -40,13 +40,12 @@ describe("caching", function () {
}); });
}); });
it("lets us set data without a callback", function (done) { it("lets us set and get data without a callback", function (done) {
cache.set(key, value); cache.set(key, value);
setTimeout(function () { setTimeout(function () {
cache.get(key, function (err, result) { var result = cache.get(key);
assert.equal(result, value); assert.equal(result, value);
done(); done();
});
}, 20); }, 20);
}); });
}); });

Loading…
Cancel
Save