adding TTL option for redis cache adapter (#3397)
* adding TTL option for redis cache adapter * adding test for RedisCacheAdapter * Fixing adapater var name * changing timeout * updating default time * Fix the redis cache spec to construct the cache with the anticipated ttl make timeout values really really small so our test run fast :).
This commit is contained in:
committed by
Arthur Cinader
parent
a45d1848db
commit
e6006e800e
@@ -9,9 +9,10 @@ function debug() {
|
||||
|
||||
export class RedisCacheAdapter {
|
||||
|
||||
constructor(ctx) {
|
||||
this.client = redis.createClient(ctx);
|
||||
constructor(redisCtx, ttl = DEFAULT_REDIS_TTL) {
|
||||
this.client = redis.createClient(redisCtx);
|
||||
this.p = Promise.resolve();
|
||||
this.ttl = ttl;
|
||||
}
|
||||
|
||||
get(key) {
|
||||
@@ -30,7 +31,7 @@ export class RedisCacheAdapter {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
put(key, value, ttl = DEFAULT_REDIS_TTL) {
|
||||
put(key, value, ttl = this.ttl) {
|
||||
value = JSON.stringify(value);
|
||||
debug('put', key, value, ttl);
|
||||
if (ttl === 0) {
|
||||
|
||||
Reference in New Issue
Block a user