diff --git a/lib/stores/memory.js b/lib/stores/memory.js index 7d2acd8..1b02648 100644 --- a/lib/stores/memory.js +++ b/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) { diff --git a/test/caching.unit.js b/test/caching.unit.js index a7c1dd1..5f1f5dc 100644 --- a/test/caching.unit.js +++ b/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); }); });