File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,9 @@ export class RedisStore extends Store {
48
48
49
49
// Create a redis and ioredis compatible client
50
50
private normalizeClient ( client : any ) : NormalizedRedisClient {
51
- let isRedis = "scanIterator" in client
51
+ let isRedis = "scanIterator" in client || "masters" in client ;
52
+ let isRedisCluster = "masters" in client ;
53
+
52
54
return {
53
55
get : ( key ) => client . get ( key ) ,
54
56
set : ( key , val , ttl ) => {
@@ -63,6 +65,19 @@ export class RedisStore extends Store {
63
65
expire : ( key , ttl ) => client . expire ( key , ttl ) ,
64
66
mget : ( keys ) => ( isRedis ? client . mGet ( keys ) : client . mget ( keys ) ) ,
65
67
scanIterator : ( match , count ) => {
68
+ // node-redis createCluster impl.
69
+ if ( isRedisCluster ) {
70
+ return ( async function * ( ) {
71
+ for ( const master of client . masters ) {
72
+ const nodeClient = await client . nodeClient ( master ) ;
73
+
74
+ for await ( const key of nodeClient . scanIterator ( { COUNT : count , MATCH : match } ) ) {
75
+ yield key ;
76
+ }
77
+ }
78
+ } ) ( ) ;
79
+ }
80
+
66
81
if ( isRedis ) return client . scanIterator ( { MATCH : match , COUNT : count } )
67
82
68
83
// ioredis impl.
You can’t perform that action at this time.
0 commit comments