Skip to content

Commit

Permalink
Merge 34a73d6 into 3e61a99
Browse files Browse the repository at this point in the history
  • Loading branch information
nucleoid committed Mar 21, 2019
2 parents 3e61a99 + 34a73d6 commit 51e076d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/redis_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ RedisCache.prototype.keys = function (pattern) {
pattern = "*";
}

return this.store.keys();
return this.store.keys(pattern);
};

/**
Expand Down
16 changes: 11 additions & 5 deletions test/redis_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,28 @@ describe("redisCache", () => {

describe("keys", () => {

const keyValues = {key1: "value1", key2: "value2"};
const keyValues = {key1: "value1", "test:key2": "value2"};

before(() => cache.deleteAll());
beforeEach(() => Promise.all(Object.keys(keyValues)
.map(key => cache.set(key, keyValues[key]))));
.map(key => cache.set(key, keyValues[key]))));

it("should return all the keys", () => {

return cache.keys()
.then(keys => keys.map(k => Object.keys(keyValues).should.containEql(k)));
});

it("should return all the keys matches pattern", () => {
it("should not return keys not matching pattern", () => {

return cache.keys("test:*")
.should.eventually.not.containEql("key1");
});

it("should return keys matches pattern", () => {

return cache.keys("key[2]")
.should.eventually.containEql("key2");
return cache.keys("test:*")
.should.eventually.containEql("test:key2");
});
});

Expand Down

0 comments on commit 51e076d

Please sign in to comment.