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

Add support for zmpop #605

Merged
merged 4 commits into from May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/commands.rs
Expand Up @@ -813,6 +813,18 @@ implement_commands! {
cmd("ZPOPMIN").arg(key).arg(count)
}

/// Removes and returns up to count members with the highest scores,
/// from the first non-empty sorted set in the provided list of key names.
fn zmpop_max<K: ToRedisArgs>(keys: &'a [K], count: isize) {
cmd("ZMPOP").arg(keys.len()).arg(keys).arg("MAX").arg("COUNT").arg(count)
}

/// Removes and returns up to count members with the lowest scores,
/// from the first non-empty sorted set in the provided list of key names.
fn zmpop_min<K: ToRedisArgs>(keys: &'a [K], count: isize) {
cmd("ZMPOP").arg(keys.len()).arg(keys).arg("MIN").arg("COUNT").arg(count)
}

/// Return up to count random members in a sorted set (or 1 if `count == None`)
fn zrandmember<K: ToRedisArgs>(key: K, count: Option<isize>) {
cmd("ZRANDMEMBER").arg(key).arg(count)
Expand Down
6 changes: 1 addition & 5 deletions src/connection.rs
Expand Up @@ -867,11 +867,7 @@ impl ConnectionLike for Connection {
}
}

if let Some(err) = first_err {
Err(err)
} else {
Ok(rv)
}
first_err.map_or(Ok(rv), Err)
}

fn get_db(&self) -> i64 {
Expand Down
2 changes: 1 addition & 1 deletion src/streams.rs
Expand Up @@ -190,7 +190,7 @@ impl ToRedisArgs for StreamReadOptions {

if let Some(ref group) = self.group {
// noack is only available w/ xreadgroup
if let Some(true) = self.noack {
if self.noack == Some(true) {
out.write_arg(b"NOACK");
}

Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Expand Up @@ -1263,7 +1263,7 @@ impl FromRedisValue for InfoDict {

impl<T: FromRedisValue> FromRedisValue for Option<T> {
fn from_redis_value(v: &Value) -> RedisResult<Option<T>> {
if let Value::Nil = *v {
if *v == Value::Nil {
return Ok(None);
}
Ok(Some(from_redis_value(v)?))
Expand Down