diff --git a/lib/caching.js b/lib/caching.js index f410a19..72e6a70 100644 --- a/lib/caching.js +++ b/lib/caching.js @@ -58,6 +58,10 @@ var caching = function (args) { self.del = self.store.del.bind(self.store); + if (typeof self.store.setex === 'function') { + self.setex = self.store.setex.bind(self.store); + } + if (typeof self.store.reset === 'function') { self.reset = self.store.reset.bind(self.store); } diff --git a/test/caching.unit.js b/test/caching.unit.js index 5f1f5dc..54b0df4 100644 --- a/test/caching.unit.js +++ b/test/caching.unit.js @@ -147,6 +147,28 @@ describe("caching", function () { }); }); + describe("setex()", function () { + var fake_store; + + beforeEach(function () { + fake_store = { + get: function () {}, + set: function () {}, + del: function () {}, + setex: function () {} + }; + + sinon.stub(fake_store, 'setex'); + + cache = caching({store: fake_store}); + }); + + it("passes the params to the underlying store's setex() method", function () { + cache.setex('foo', 'bar', 'blah'); + assert.ok(fake_store.setex.calledWith('foo', 'bar', 'blah')); + }); + }); + describe("keys()", function () { var key_count; var saved_keys = [];