Skip to content

Commit fc07dd6

Browse files
committed
polish pass
1 parent 1b4b517 commit fc07dd6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/redis-adapter.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const INTEGRATION_MODE = Object.freeze({
2424
NO_REDIS: "NO_REDIS",
2525
});
2626
const CF_REDIS_SERVICE_LABEL = "redis-cache";
27+
const REDIS_CLIENT_DEFAULT_PING_INTERVAL = 5 * 60000;
2728

2829
const cfEnv = CfEnv.getInstance();
2930
const logger = new Logger(COMPONENT_NAME);
@@ -99,11 +100,11 @@ const _createClientBase = (clientName) => {
99100
} = cfEnv.cfServiceCredentialsForLabel(CF_REDIS_SERVICE_LABEL);
100101
const redisClientOptions = {
101102
password,
102-
pingInterval: 5 * 60000,
103+
pingInterval: REDIS_CLIENT_DEFAULT_PING_INTERVAL,
103104
socket: {
104105
host,
105106
port,
106-
tls,
107+
...(tls !== undefined && { tls }),
107108
},
108109
};
109110
if (isCluster) {
@@ -256,8 +257,8 @@ const sendCommand = async (command) => {
256257
}
257258

258259
try {
259-
const redisIsCluster = cfEnv.cfServiceCredentialsForLabel(CF_REDIS_SERVICE_LABEL).cluster_mode;
260-
if (redisIsCluster) {
260+
const { cluster_mode: isCluster } = cfEnv.cfServiceCredentialsForLabel(CF_REDIS_SERVICE_LABEL);
261+
if (isCluster) {
261262
// NOTE: the cluster sendCommand API has a different signature, where it takes two optional args: firstKey and
262263
// isReadonly before the command
263264
return await mainClient.sendCommand(undefined, undefined, command);
@@ -555,8 +556,8 @@ const _getIntegrationMode = async () => {
555556
return INTEGRATION_MODE.NO_REDIS;
556557
}
557558
if (cfEnv.isOnCf) {
558-
const redisIsCluster = cfEnv.cfServiceCredentialsForLabel(CF_REDIS_SERVICE_LABEL).cluster_mode;
559-
return redisIsCluster ? INTEGRATION_MODE.CF_REDIS_CLUSTER : INTEGRATION_MODE.CF_REDIS;
559+
const { cluster_mode: isCluster } = cfEnv.cfServiceCredentialsForLabel(CF_REDIS_SERVICE_LABEL);
560+
return isCluster ? INTEGRATION_MODE.CF_REDIS_CLUSTER : INTEGRATION_MODE.CF_REDIS;
560561
}
561562
return INTEGRATION_MODE.LOCAL_REDIS;
562563
};

0 commit comments

Comments
 (0)