@@ -24,6 +24,7 @@ const INTEGRATION_MODE = Object.freeze({
24
24
NO_REDIS : "NO_REDIS" ,
25
25
} ) ;
26
26
const CF_REDIS_SERVICE_LABEL = "redis-cache" ;
27
+ const REDIS_CLIENT_DEFAULT_PING_INTERVAL = 5 * 60000 ;
27
28
28
29
const cfEnv = CfEnv . getInstance ( ) ;
29
30
const logger = new Logger ( COMPONENT_NAME ) ;
@@ -99,11 +100,11 @@ const _createClientBase = (clientName) => {
99
100
} = cfEnv . cfServiceCredentialsForLabel ( CF_REDIS_SERVICE_LABEL ) ;
100
101
const redisClientOptions = {
101
102
password,
102
- pingInterval : 5 * 60000 ,
103
+ pingInterval : REDIS_CLIENT_DEFAULT_PING_INTERVAL ,
103
104
socket : {
104
105
host,
105
106
port,
106
- tls,
107
+ ... ( tls !== undefined && { tls } ) ,
107
108
} ,
108
109
} ;
109
110
if ( isCluster ) {
@@ -256,8 +257,8 @@ const sendCommand = async (command) => {
256
257
}
257
258
258
259
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 ) {
261
262
// NOTE: the cluster sendCommand API has a different signature, where it takes two optional args: firstKey and
262
263
// isReadonly before the command
263
264
return await mainClient . sendCommand ( undefined , undefined , command ) ;
@@ -555,8 +556,8 @@ const _getIntegrationMode = async () => {
555
556
return INTEGRATION_MODE . NO_REDIS ;
556
557
}
557
558
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 ;
560
561
}
561
562
return INTEGRATION_MODE . LOCAL_REDIS ;
562
563
} ;
0 commit comments