Skip to content
Merged
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
19 changes: 14 additions & 5 deletions spec/RedisCacheAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,26 @@ describe('RedisCacheAdapter', function() {
});

it('should expire after ttl', (done) => {
var cache = new RedisCacheAdapter({
ttl: 100
});
var cache = new RedisCacheAdapter(null, 1);

cache.put(KEY, VALUE)
.then(() => cache.get(KEY))
.then((value) => expect(value).toEqual(VALUE))
.then(wait.bind(null, 1000))
.then(wait.bind(null, 2))
.then(() => cache.get(KEY))
.then((value) => expect(value).toEqual(null))
.then(done);
})
});

it('should find un-expired records', (done) => {
var cache = new RedisCacheAdapter(null, 5);

cache.put(KEY, VALUE)
.then(() => cache.get(KEY))
.then((value) => expect(value).toEqual(VALUE))
.then(wait.bind(null, 1))
.then(() => cache.get(KEY))
.then((value) => expect(value).not.toEqual(null))
.then(done);
});
});
2 changes: 1 addition & 1 deletion src/Adapters/Cache/RedisCacheAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import redis from 'redis';
import logger from '../../logger';

const DEFAULT_REDIS_TTL = 30000; // 30 seconds in milliseconds
const DEFAULT_REDIS_TTL = 30 * 1000; // 30 seconds in milliseconds

function debug() {
logger.debug.apply(logger, ['RedisCacheAdapter', ...arguments]);
Expand Down