-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add scan commands #95
Conversation
This adds support for SCAN, ZSCAN, SSCAN, and HSCAN. They're all fairly low level, as they return the cursor and leave the rest up to the caller.
ZSCAN can return multiple items with the same score. Returning a Map keyed on score would cause some items to be dropped. A Seq of tuples should work correctly.
def decodeResponses(responses: Seq[RedisReply]) = | ||
responses.grouped(2).map { xs => | ||
val data = xs.head | ||
val score = xs(1).toByteString.utf8String.toDouble |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#93
;)
Maybe launch Scan Test with his own redis Server? |
@@ -91,4 +91,7 @@ trait Keys extends Request { | |||
def `type`(key: String): Future[String] = | |||
send(Type(key)) | |||
|
|||
def scan(cursor: Int = 0, count: Option[Int] = None, matchGlob: Option[String] = None): Future[(Int, Seq[String])] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could use for Scan Replies
case class Cursor[T](index:Int, data:Seq[T])
instead of (Int, Seq[T])
(feel free to rename if needed)
I'm not sure I understand. Do you mean I should put the scan commands in a separate test file and run them with a different Redis process? |
Yes sorry, |
@actsasbuffoon This looks like good work. I am interested in seeing these commands in rediscala as well. |
thanks It should be in 1.6.0-SNAPSHOT in the next hour |
"com.github.etaty" %% "rediscala" % "1.6.0-SNAPSHOT" |
There's been an open issue in the issue tracker for a while about adding support for new commands from Redis 2.8: #21
This adds support for SCAN, ZSCAN, SSCAN, and HSCAN. They're all fairly low level, as they return the cursor and leave the rest up to the caller. It would be convenient to have higher-level methods for iterating over the entire result, but I figured this was a decent starting point.
My apologies about the tests. The scan commands are all quite non-deterministic, which makes them challenging to test. I'm happy to take suggestions about how to improve these.