Skip to content

Commit 806e594

Browse files
committed
fix: give redis it's own variable for its prefix
The standard "ENVIRONMENT" is not unique across environments
1 parent f295ce1 commit 806e594

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

backend/src/config/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ nconf.defaults({
7272
password: process.env.REDIS_PASSWORD,
7373
clustered: process.env.REDIS_USE_CLUSTERED,
7474
estimatorFacilityTTL: process.env.REDIS_FACILITY_TTL,
75+
prefix: process.env.REDIS_PREFIX,
7576
},
7677
canadaPostApi: {
7778
apiEndpoint: process.env.CANADA_POST_API_ENDPOINT,

backend/src/util/redis/redis-client.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const log = require('../../components/logger');
44

55
class Redis {
66
static client;
7-
static prefix = config.get('environment');
7+
static prefix = config.get('redis:prefix');
88

99
static async shutdown(signal = 'quit') {
1010
log.info(`Received ${signal}, closing Redis connection`);
@@ -47,7 +47,7 @@ class Redis {
4747
* @param {args} args - The rest of the command args
4848
*/
4949
static async get(key, ...args) {
50-
return Redis.client.get(`${Redis.prefix}:${key}`, ...args);
50+
return Redis.client.get(`${Redis.prefix}${key}`, ...args);
5151
}
5252

5353
/**
@@ -58,7 +58,7 @@ class Redis {
5858
* @param {args} args - The rest of the command args
5959
*/
6060
static async set(key, ...args) {
61-
return Redis.client.set(`${Redis.prefix}:${key}`, ...args);
61+
return Redis.client.set(`${Redis.prefix}${key}`, ...args);
6262
}
6363

6464
/**
@@ -69,7 +69,7 @@ class Redis {
6969
* @param {args} args - The rest of the command args
7070
*/
7171
static async jsonGet(key, ...args) {
72-
return Redis.client.json.get(`${Redis.prefix}:${key}`, ...args);
72+
return Redis.client.json.get(`${Redis.prefix}${key}`, ...args);
7373
}
7474

7575
/**
@@ -80,7 +80,7 @@ class Redis {
8080
* @param {args} args - The rest of the command args
8181
*/
8282
static async jsonSet(key, ...args) {
83-
return Redis.client.json.set(`${Redis.prefix}:${key}`, ...args);
83+
return Redis.client.json.set(`${Redis.prefix}${key}`, ...args);
8484
}
8585

8686
/**
@@ -91,7 +91,7 @@ class Redis {
9191
* @param {args} args - The rest of the command args
9292
*/
9393
static async expire(key, ...args) {
94-
return Redis.client.expire(`${Redis.prefix}:${key}`, ...args);
94+
return Redis.client.expire(`${Redis.prefix}${key}`, ...args);
9595
}
9696

9797
static async init() {

tools/config/update-configmap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ oc create -n "$OPENSHIFT_NAMESPACE" configmap \
100100
--from-literal="REDIS_HOST=redis" \
101101
--from-literal="REDIS_PORT=6379" \
102102
--from-literal="REDIS_FACILITY_TTL=600" \
103+
--from-literal="REDIS_PREFIX=$ENV_VAL:" \
103104
--from-literal="SERVER_FRONTEND=$SERVER_FRONTEND" \
104105
--from-literal="SERVER_PORT=8080" \
105106
--from-literal="SITEMINDER_LOGOUT_ENDPOINT=$SITE_MINDER_LOGOUT_URL" \

0 commit comments

Comments
 (0)