File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,21 @@ import Redis from 'ioredis';
4
4
const connectionMap = new Map < Options [ 'redis' ] , Redis . Redis > ( ) ;
5
5
6
6
export function getBullConnection ( opts : Options ) : Redis . Redis {
7
- let connection = connectionMap . get ( opts . redis ) ;
7
+ const optsRedis = opts ?. redis ;
8
+ let connection = connectionMap . get ( optsRedis ) ;
8
9
if ( connection ) {
9
10
return connection ;
10
11
}
11
12
12
- if ( opts ?. redis instanceof Redis ) {
13
- connection = opts . redis ;
14
- } else if ( opts ?. redis ) {
15
- connection = new Redis ( opts . redis ) ;
13
+ if ( optsRedis instanceof Redis || optsRedis ?. constructor ?. name === ' Redis' ) {
14
+ connection = optsRedis as Redis . Redis ;
15
+ } else if ( optsRedis ) {
16
+ connection = new Redis ( optsRedis ) ;
16
17
} else {
17
18
connection = new Redis ( ) ;
18
19
}
19
20
20
- connectionMap . set ( opts . redis , connection ) ;
21
+ connectionMap . set ( optsRedis , connection ) ;
21
22
22
23
return connection ;
23
24
}
You can’t perform that action at this time.
0 commit comments