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) {
process.nextTick(function () {
cb(null, lru_cache.get(key));
});
var value = lru_cache.get(key);
if (cb) {
process.nextTick(function () {
cb(null, value);
});
} else {
return value;
}
};
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);
setTimeout(function () {
cache.get(key, function (err, result) {
assert.equal(result, value);
done();
});
var result = cache.get(key);
assert.equal(result, value);
done();
}, 20);
});
});

Loading…
Cancel
Save