Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCAN never terminates #971

Open
russwyte opened this issue Jun 12, 2024 · 0 comments
Open

SCAN never terminates #971

russwyte opened this issue Jun 12, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@russwyte
Copy link

russwyte commented Jun 12, 2024

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
@mijicd mijicd added the bug Something isn't working label Jun 24, 2024
@mijicd mijicd added this to the 1.1.0 milestone Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants