Fix list route

This commit is contained in:
Jacob Gunther
2023-05-02 20:56:31 -05:00
parent 953eb04476
commit 028503bf36
2 changed files with 4 additions and 4 deletions

View File

@@ -35,12 +35,12 @@ func (r *Redis) Connect(conf RedisConfig) error {
}
// 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)
defer cancel()
res := r.conn.Scan(ctx, cursor, pattern, 25)
res := r.conn.Scan(ctx, cursor, pattern, count)
if err := res.Err(); err != nil {
return nil, 0, err

View File

@@ -44,7 +44,7 @@ func ListHandler(ctx *fiber.Ctx) error {
result := make([]string, 0)
for {
keys, cursor, err := r.Scan(0, "unique:*")
keys, cursor, err := r.Scan(0, "unique:*", 25)
if err != nil {
return err
@@ -54,7 +54,7 @@ func ListHandler(ctx *fiber.Ctx) error {
result = append(result, strings.TrimPrefix(uuid, "unique:"))
}
if cursor == 0 || len(keys) < 1 {
if cursor == 0 {
break
}
}