Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ class AdapterCacheRedis extends BaseCacheAdapter {
this.cache.get(key).then((result) => {
clearTimeout(timer);
resolve(result);
}).catch(() => {
clearTimeout(timer);
resolve(null);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ describe('Adapter Cache Redis', function () {
assert.equal(value, 'value from cache');
});

it('returns null if the cache get rejects and getTimeoutMilliseconds is set', async function () {
const redisCacheInstanceStub = {
get: sinon.stub().rejects(new Error('Stream isn\'t writeable and enableOfflineQueue options is false')),
store: {
getClient: sinon.stub().returns({
on: sinon.stub()
})
}
};
const cache = new RedisCache({
cache: redisCacheInstanceStub,
getTimeoutMilliseconds: 100
});

const value = await cache.get('key');
assert.equal(value, null);
});

it('returns null if getTimeoutMilliseconds is exceeded', async function () {
const redisCacheInstanceStub = {
get: sinon.stub().callsFake(async () => {
Expand Down
Loading