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

[Compatibility] Added ZRANGESTORE command #826

Merged
merged 15 commits into from
Dec 8, 2024
Merged
Prev Previous commit
Next Next commit
Merge latest
  • Loading branch information
Vijay-Nirmal committed Dec 5, 2024
commit c86d1f882b2ae1fb8707d406945a60d7736740a2
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class ClusterSlotVerificationTests
new ZREM(),
new ZCARD(),
new ZRANGE(),
new ZREVRANGEBYLEX(),
new ZRANGESTORE(),
new ZSCORE(),
new ZMSCORE(),
Expand Down Expand Up @@ -277,6 +278,7 @@ public virtual void OneTimeTearDown()
[TestCase("ZREM")]
[TestCase("ZCARD")]
[TestCase("ZRANGE")]
[TestCase("ZREVRANGEBYLEX")]
[TestCase("ZRANGESTORE")]
[TestCase("ZSCORE")]
[TestCase("ZMSCORE")]
Expand Down Expand Up @@ -418,6 +420,7 @@ void GarnetClientSessionClusterDown(BaseCommand command)
[TestCase("ZREM")]
[TestCase("ZCARD")]
[TestCase("ZRANGE")]
[TestCase("ZREVRANGEBYLEX")]
[TestCase("ZRANGESTORE")]
[TestCase("ZSCORE")]
[TestCase("ZMSCORE")]
Expand Down Expand Up @@ -569,6 +572,7 @@ void GarnetClientSessionOK(BaseCommand command)
[TestCase("ZREM")]
[TestCase("ZCARD")]
[TestCase("ZRANGE")]
[TestCase("ZREVRANGEBYLEX")]
[TestCase("ZRANGESTORE")]
[TestCase("ZSCORE")]
[TestCase("ZMSCORE")]
Expand Down Expand Up @@ -712,6 +716,7 @@ void GarnetClientSessionCrossslotTest(BaseCommand command)
[TestCase("ZREM")]
[TestCase("ZCARD")]
[TestCase("ZRANGE")]
[TestCase("ZREVRANGEBYLEX")]
[TestCase("ZRANGESTORE")]
[TestCase("ZSCORE")]
[TestCase("ZMSCORE")]
Expand Down Expand Up @@ -862,6 +867,7 @@ void GarnetClientSessionMOVEDTest(BaseCommand command)
[TestCase("ZREM")]
[TestCase("ZCARD")]
[TestCase("ZRANGE")]
[TestCase("ZREVRANGEBYLEX")]
[TestCase("ZRANGESTORE")]
[TestCase("ZSCORE")]
[TestCase("ZMSCORE")]
Expand Down Expand Up @@ -1029,6 +1035,7 @@ void GarnetClientSessionASKTest(BaseCommand command)
[TestCase("ZREM")]
[TestCase("ZCARD")]
[TestCase("ZRANGE")]
[TestCase("ZREVRANGEBYLEX")]
[TestCase("ZRANGESTORE")]
[TestCase("ZSCORE")]
[TestCase("ZMSCORE")]
Expand Down
15 changes: 15 additions & 0 deletions test/Garnet.test/Resp/ACL/RespCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5720,6 +5720,21 @@ static async Task DoZRangeAsync(GarnetClient client)
}
}

[Test]
public async Task ZRevRangeByLexACLsAsync()
{
await CheckCommandsAsync(
"ZREVRANGEBYLEX",
[DoZRevRangeByLexAsync]
);

static async Task DoZRevRangeByLexAsync(GarnetClient client)
{
string[] val = await client.ExecuteForStringArrayResultAsync("ZREVRANGEBYLEX", ["key", "10", "20"]);
ClassicAssert.AreEqual(0, val.Length);
}
}

[Test]
public async Task ZRangeStoreACLsAsync()
{
Expand Down
40 changes: 40 additions & 0 deletions test/Garnet.test/RespSortedSetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,46 @@ public void CheckSortedSetDifferenceStoreWithNoMatchSE()
ClassicAssert.AreEqual(0, actualMembers.Length);
}

[Test]
[TestCase("(a", "(a", new string[] { })]
public void CanDoZRevRangeByLex(string max, string min, string[] expected, int offset = 0, int count = -1)
{
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
var db = redis.GetDatabase(0);

var key = "myzset";
db.SortedSetAdd(key, "a", 0);
db.SortedSetAdd(key, "b", 0);
db.SortedSetAdd(key, "c", 0);
db.SortedSetAdd(key, "d", 0);
db.SortedSetAdd(key, "e", 0);
db.SortedSetAdd(key, "f", 0);
db.SortedSetAdd(key, "g", 0);

var result = (string[])db.Execute("ZREVRANGEBYLEX", key, max, min, "LIMIT", offset, count);
CollectionAssert.AreEqual(expected, result);
}

[Test]
[TestCase("(a", "(a", new string[] { })]
public void CanDoZRevRangeByLexWithoutLimit(string min, string max, string[] expected)
{
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
var db = redis.GetDatabase(0);

var key = "myzset";
db.SortedSetAdd(key, "a", 0);
db.SortedSetAdd(key, "b", 0);
db.SortedSetAdd(key, "c", 0);
db.SortedSetAdd(key, "d", 0);
db.SortedSetAdd(key, "e", 0);
db.SortedSetAdd(key, "f", 0);
db.SortedSetAdd(key, "g", 0);

var result = (string[])db.Execute("ZREVRANGEBYLEX", key, max, min);
ClassicAssert.AreEqual(expected, result);
}

[Test]
[TestCase("user1:obj1", "user1:objA", new[] { "Hello", "World" }, new[] { 1.0, 2.0 }, new[] { "Hello", "World" }, new[] { 1.0, 2.0 })] // Normal case
[TestCase("user1:emptySet", "user1:objB", new string[] { }, new double[] { }, new string[] { }, new double[] { })] // Empty set
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.