From 8502cf7533b4fb26d0141a8945ac11fd118e397f Mon Sep 17 00:00:00 2001 From: Jeremy Woertink Date: Mon, 19 Sep 2022 15:18:40 -0700 Subject: [PATCH] Add ZSCORE command (#24) * Adding ZSCORE command support * oops... --- spec/redis_spec.cr | 5 +++++ src/commands/sorted_set.cr | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/spec/redis_spec.cr b/spec/redis_spec.cr index e8b4b13..7549550 100644 --- a/spec/redis_spec.cr +++ b/spec/redis_spec.cr @@ -199,6 +199,11 @@ describe Redis::Client do redis.zcount(key, "0", "+inf").should eq(3) redis.zcount(key, "(1", "3").should eq(2) end + + test "returns the score of a member in a sorted set at key" do + redis.zadd(key, "1", "one") + redis.zscore(key, "one").should eq("1") + end end describe "hash" do diff --git a/src/commands/sorted_set.cr b/src/commands/sorted_set.cr index 5358c32..35ccff9 100644 --- a/src/commands/sorted_set.cr +++ b/src/commands/sorted_set.cr @@ -58,4 +58,8 @@ module Redis::Commands::SortedSet def zcount(key : String, min : String, max : String) run({"zcount", key, min, max}) end + + def zscore(key : String, value : String) + run({"zscore", key, value}) + end end