File tree 1 file changed +19
-1
lines changed
1 file changed +19
-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,22 @@ 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 ( {
75
+ COUNT : count ,
76
+ MATCH : match ,
77
+ } ) ) {
78
+ yield key
79
+ }
80
+ }
81
+ } ) ( )
82
+ }
83
+
66
84
if ( isRedis ) return client . scanIterator ( { MATCH : match , COUNT : count } )
67
85
68
86
// ioredis impl.
You can’t perform that action at this time.
0 commit comments