Skip to content
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

Merged
merged 5 commits into from
Dec 5, 2015
Merged

Add scan commands #95

merged 5 commits into from
Dec 5, 2015

Conversation

actsasbuffoon
Copy link
Contributor

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.

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#93
;)

@etaty
Copy link
Owner

etaty commented Sep 25, 2015

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])] =
Copy link
Owner

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)

@actsasbuffoon
Copy link
Contributor Author

@etaty:
Maybe launch Scan Test with his own redis Server?

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?

@etaty
Copy link
Owner

etaty commented Sep 28, 2015

@acaloiaro
Copy link

@actsasbuffoon This looks like good work. I am interested in seeing these commands in rediscala as well.

etaty added a commit that referenced this pull request Dec 5, 2015
@etaty etaty merged commit ecd2c7b into etaty:master Dec 5, 2015
@etaty
Copy link
Owner

etaty commented Dec 5, 2015

thanks It should be in 1.6.0-SNAPSHOT in the next hour

@etaty
Copy link
Owner

etaty commented Dec 5, 2015

"com.github.etaty" %% "rediscala" % "1.6.0-SNAPSHOT"

@etaty etaty added this to the 1.6.0 milestone Jan 3, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants