back/redis: fix not using redis.prefix config

This commit is contained in:
Alice Gaudon 2021-11-28 17:05:50 +01:00
parent be0676611a
commit ae603362e9

View File

@ -8,6 +8,7 @@ import CacheProvider from "../CacheProvider.js";
import {logger} from "../Logger.js";
export default class RedisComponent extends ApplicationComponent implements CacheProvider {
private readonly prefix: string = config.get('redis.prefix');
private redisClient?: RedisClient;
private store: Store = new RedisStore(this);
@ -42,7 +43,7 @@ export default class RedisComponent extends ApplicationComponent implements Cach
return;
}
this.redisClient.get(key, (err, val) => {
this.redisClient.get(this.prefix + key, (err, val) => {
if (err) {
reject(err);
return;
@ -63,7 +64,7 @@ export default class RedisComponent extends ApplicationComponent implements Cach
return;
}
this.redisClient.del(key, (err) => {
this.redisClient.del(this.prefix + key, (err) => {
if (err) {
reject(err);
return;
@ -81,7 +82,7 @@ export default class RedisComponent extends ApplicationComponent implements Cach
return;
}
this.redisClient.psetex(key, ttl, value, (err) => {
this.redisClient.psetex(this.prefix + key, ttl, value, (err) => {
if (err) return reject(err);
resolve();
});
@ -95,7 +96,7 @@ export default class RedisComponent extends ApplicationComponent implements Cach
return;
}
this.redisClient.pexpire(key, ttl, (err) => {
this.redisClient.pexpire(this.prefix + key, ttl, (err) => {
if (err) return reject(err);
resolve();
});