debasishg / scala-redis-nb

Implementation of a non blocking Redis client in Scala using Akka IO
204 stars 38 forks source link

zrank in a loop returns wrong ranks #82

Closed aktasonur closed 10 years ago

aktasonur commented 10 years ago

Hi,

There is no problem with a single zrank call, it returns correct rank result.

However when I call zrank in a loop for multiple members, only 1 or 2 of 15 calls returned correct rank value; the rest returns None even though the members exist in SortedSet!,

Future.traverse(userIds)(userId =>
      Redis.client.zrank(key, userId).map {
        rank=>
          (userId, rank.isDefined) // returns incorrect values
      })

It does not matter if I use with Future.traverse or Future.sequence or a simple scala loop.

Thanks

debasishg commented 10 years ago

Thanks for reporting. Will take a look very soon.

aktasonur commented 10 years ago

It is resolved. Instead of calling Redis.client.zrank method directly, I changed it to send a message to the actor itself which is doing the same job when it receives a message case class RankOfUserId.

Future.traverse(userIds)(userId =>
   self ? RankOfUserId(userId)
   ....

Now results return correctly. It might be because of futures; not the driver at all.