File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 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';
44const connectionMap = new Map < Options [ 'redis' ] , Redis . Redis > ( ) ;
55
66export function getBullConnection ( opts : Options ) : Redis . Redis {
7- let connection = connectionMap . get ( opts . redis ) ;
7+ const optsRedis = opts ?. redis ;
8+ let connection = connectionMap . get ( optsRedis ) ;
89 if ( connection ) {
910 return connection ;
1011 }
1112
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 ) ;
1617 } else {
1718 connection = new Redis ( ) ;
1819 }
1920
20- connectionMap . set ( opts . redis , connection ) ;
21+ connectionMap . set ( optsRedis , connection ) ;
2122
2223 return connection ;
2324}
You can’t perform that action at this time.
0 commit comments