|
@ -18,37 +18,21 @@ describe("caching", function () { |
|
|
var value; |
|
|
var value; |
|
|
|
|
|
|
|
|
describe("get() and set()", function () { |
|
|
describe("get() and set()", function () { |
|
|
context("using redis store", function () { |
|
|
['redis', 'memory'].forEach(function (store) { |
|
|
beforeEach(function () { |
|
|
context("using " + store + " store", function () { |
|
|
cache = caching({store: 'redis'}); |
|
|
beforeEach(function () { |
|
|
key = support.random.string(20); |
|
|
cache = caching({store: store}); |
|
|
value = support.random.string(); |
|
|
key = support.random.string(20); |
|
|
}); |
|
|
value = support.random.string(); |
|
|
|
|
|
|
|
|
it("lets us set and get data in cache", function (done) { |
|
|
|
|
|
cache.set(key, value, function (err) { |
|
|
|
|
|
check_err(err); |
|
|
|
|
|
cache.get(key, function (err, result) { |
|
|
|
|
|
assert.equal(result, value); |
|
|
|
|
|
done(); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
context("using memory store", function () { |
|
|
|
|
|
beforeEach(function () { |
|
|
|
|
|
cache = caching({store: 'memory'}); |
|
|
|
|
|
key = support.random.string(20); |
|
|
|
|
|
value = support.random.string(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it("lets us set and get data in cache", function (done) { |
|
|
it("lets us set and get data in cache", function (done) { |
|
|
cache.set(key, value, function (err) { |
|
|
cache.set(key, value, function (err) { |
|
|
check_err(err); |
|
|
check_err(err); |
|
|
cache.get(key, function (err, result) { |
|
|
cache.get(key, function (err, result) { |
|
|
assert.equal(result, value); |
|
|
assert.equal(result, value); |
|
|
done(); |
|
|
done(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|