Fix list route
This commit is contained in:
@@ -35,12 +35,12 @@ func (r *Redis) Connect(conf RedisConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scan returns all keys by the pattern in the Redis database.
|
// Scan returns all keys by the pattern in the Redis database.
|
||||||
func (r *Redis) Scan(cursor uint64, pattern string) ([]string, uint64, error) {
|
func (r *Redis) Scan(cursor uint64, pattern string, count int64) ([]string, uint64, error) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||||
|
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
res := r.conn.Scan(ctx, cursor, pattern, 25)
|
res := r.conn.Scan(ctx, cursor, pattern, count)
|
||||||
|
|
||||||
if err := res.Err(); err != nil {
|
if err := res.Err(); err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func ListHandler(ctx *fiber.Ctx) error {
|
|||||||
result := make([]string, 0)
|
result := make([]string, 0)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
keys, cursor, err := r.Scan(0, "unique:*")
|
keys, cursor, err := r.Scan(0, "unique:*", 25)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -54,7 +54,7 @@ func ListHandler(ctx *fiber.Ctx) error {
|
|||||||
result = append(result, strings.TrimPrefix(uuid, "unique:"))
|
result = append(result, strings.TrimPrefix(uuid, "unique:"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if cursor == 0 || len(keys) < 1 {
|
if cursor == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user