@@ -338,7 +338,7 @@ func (c *client) Scan(cursor uint64, key string, count int64) (uint64, []string,
338338
339339 if c .clientType == ClientTypeCluster {
340340 // Use cluster-aware pagination
341- keys , newCursor , err = c .scanClusterWithPagination (cursor , key , count )
341+ newCursor , keys , err = c .scanClusterWithPagination (cursor , key , count )
342342 } else {
343343 // Use standard approach for non-cluster client
344344 keys , newCursor , err = c .rc .Scan (context .TODO (), cursor , key , count ).Result ()
@@ -359,16 +359,16 @@ func (c *client) Scan(cursor uint64, key string, count int64) (uint64, []string,
359359
360360// scanClusterWithPagination implements cursor-based pagination across cluster nodes
361361// For cluster clients, we collect keys from all master nodes in a single call to avoid connection issues
362- func (c * client ) scanClusterWithPagination (cursor uint64 , key string , count int64 ) ([]string , uint64 , error ) {
362+ func (c * client ) scanClusterWithPagination (cursor uint64 , key string , count int64 ) (uint64 , []string , error ) {
363363 clusterClient , ok := c .rc .(* goredis.ClusterClient )
364364 if ! ok {
365- return nil , 0 , fmt .Errorf ("client is not a cluster client" )
365+ return 0 , nil , fmt .Errorf ("client is not a cluster client" )
366366 }
367367
368368 // For cluster scanning, if cursor is 0, scan all nodes and return all keys
369369 // If cursor is non-zero, we've already completed the scan
370370 if cursor != 0 {
371- return []string {}, 0 , nil
371+ return 0 , []string {}, nil
372372 }
373373
374374 var allKeys []string
@@ -388,11 +388,11 @@ func (c *client) scanClusterWithPagination(cursor uint64, key string, count int6
388388 return nil
389389 })
390390 if err != nil {
391- return nil , 0 , err
391+ return 0 , nil , err
392392 }
393393
394- // Return all keys with cursor=1 to indicate completion
395- return allKeys , 1 , nil
394+ // Return all keys with cursor=0 to indicate completion
395+ return 0 , allKeys , nil
396396}
397397
398398func (c * client ) Get (key string ) ([]byte , error ) {
0 commit comments