Skip to content

SCAN never terminates #971

Open
Open
@russwyte

Description

When using SCAN to get keys - the scan method never returns a 0 cursor - resulting in infinite recursion.

example that should work but does not:

  def findKeys(pattern: String): IO[RedisError, Chunk[String]] =
    def loop(cursor: Long, acc: Chunk[String]): Result[Chunk[String]] =
      manager.redis
        .scan(cursor, Some(pattern))
        .returning[String]
        .flatMap { case (nextCursor, keys) =>
          if nextCursor == 0L then ZIO.succeed((acc ++ keys).distinct)
          else loop(nextCursor, acc ++ keys)
        }
    end loop
    loop(0L, Chunk.empty)
  end findKeys

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions