File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ export class RedisClient {
11
11
return ;
12
12
}
13
13
14
- this . client = new Redis ( config . REDIS_URL , {
14
+ const redisUrl = this . getRedisURL ( ) ;
15
+
16
+ this . client = new Redis ( redisUrl , {
15
17
reconnectOnError : ( err ) => {
16
18
const targetError = "READONLY" ;
17
19
if ( err . message . includes ( targetError ) ) {
@@ -30,6 +32,16 @@ export class RedisClient {
30
32
} ) ;
31
33
}
32
34
35
+ private getRedisURL ( ) : string {
36
+ const hasQueryParams = config . REDIS_URL . includes ( "?" ) ;
37
+
38
+ if ( config . REDIS_URL . includes ( "rediss" ) ) {
39
+ return hasQueryParams ? `${ config . REDIS_URL } &tls=true` : `${ config . REDIS_URL } ?tls=true` ;
40
+ }
41
+
42
+ return config . REDIS_URL ;
43
+ }
44
+
33
45
public static getInstance ( ) : RedisClient {
34
46
if ( ! RedisClient . instance ) {
35
47
RedisClient . instance = new RedisClient ( ) ;
You can’t perform that action at this time.
0 commit comments