Skip to content

Commit 1b706ed

Browse files
authored
Sorted Set Commands (GA) Part 1 (#29)
1 parent 6d77c8a commit 1b706ed

File tree

11 files changed

+1678
-283
lines changed

11 files changed

+1678
-283
lines changed

sources/Valkey.Glide/BaseClient.SortedSetCommands.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,77 @@ public async Task<ValkeyValue[]> SortedSetRangeByValueAsync(
108108
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
109109
return await Command(Request.SortedSetRangeByValueAsync(key, min, max, exclude, order, skip, take));
110110
}
111+
112+
public async Task<ValkeyValue[]> SortedSetCombineAsync(SetOperation operation, ValkeyKey[] keys, double[]? weights = null, Aggregate aggregate = Aggregate.Sum, CommandFlags flags = CommandFlags.None)
113+
{
114+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
115+
return await Command(Request.SortedSetCombineAsync(operation, keys, weights, aggregate));
116+
}
117+
118+
public async Task<SortedSetEntry[]> SortedSetCombineWithScoresAsync(SetOperation operation, ValkeyKey[] keys, double[]? weights = null, Aggregate aggregate = Aggregate.Sum, CommandFlags flags = CommandFlags.None)
119+
{
120+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
121+
return await Command(Request.SortedSetCombineWithScoresAsync(operation, keys, weights, aggregate));
122+
}
123+
124+
public async Task<long> SortedSetCombineAndStoreAsync(SetOperation operation, ValkeyKey destination, ValkeyKey first, ValkeyKey second, Aggregate aggregate = Aggregate.Sum, CommandFlags flags = CommandFlags.None)
125+
{
126+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
127+
return await Command(Request.SortedSetCombineAndStoreAsync(operation, destination, first, second, aggregate));
128+
}
129+
130+
public async Task<long> SortedSetCombineAndStoreAsync(SetOperation operation, ValkeyKey destination, ValkeyKey[] keys, double[]? weights = null, Aggregate aggregate = Aggregate.Sum, CommandFlags flags = CommandFlags.None)
131+
{
132+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
133+
return await Command(Request.SortedSetCombineAndStoreAsync(operation, destination, keys, weights, aggregate));
134+
}
135+
136+
public async Task<double> SortedSetIncrementAsync(ValkeyKey key, ValkeyValue member, double value, CommandFlags flags = CommandFlags.None)
137+
{
138+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
139+
return await Command(Request.SortedSetIncrementAsync(key, member, value));
140+
}
141+
142+
public async Task<long> SortedSetIntersectionLengthAsync(ValkeyKey[] keys, long limit = 0, CommandFlags flags = CommandFlags.None)
143+
{
144+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
145+
return await Command(Request.SortedSetIntersectionLengthAsync(keys, limit));
146+
}
147+
148+
public async Task<long> SortedSetLengthByValueAsync(ValkeyKey key, ValkeyValue min, ValkeyValue max, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None)
149+
{
150+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
151+
return await Command(Request.SortedSetLengthByValueAsync(key, min, max, exclude));
152+
}
153+
154+
public async Task<SortedSetPopResult> SortedSetPopAsync(ValkeyKey[] keys, long count, Order order = Order.Ascending, CommandFlags flags = CommandFlags.None)
155+
{
156+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
157+
return await Command(Request.SortedSetPopAsync(keys, count, order));
158+
}
159+
160+
public async Task<double?[]> SortedSetScoresAsync(ValkeyKey key, ValkeyValue[] members, CommandFlags flags = CommandFlags.None)
161+
{
162+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
163+
return await Command(Request.SortedSetScoresAsync(key, members));
164+
}
165+
166+
public async Task<SortedSetEntry?> SortedSetBlockingPopAsync(ValkeyKey key, Order order, double timeout, CommandFlags flags = CommandFlags.None)
167+
{
168+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
169+
return await Command(Request.SortedSetBlockingPopAsync(key, order, timeout));
170+
}
171+
172+
public async Task<SortedSetEntry[]> SortedSetBlockingPopAsync(ValkeyKey key, long count, Order order, double timeout, CommandFlags flags = CommandFlags.None)
173+
{
174+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
175+
Utils.Requires<ArgumentException>(count == 1, "GLIDE does not currently support multipop BZPOPMIN or BZPOPMAX"); // TODO for the future
176+
return await Command(Request.SortedSetBlockingPopAsync(key, count, order, timeout));
177+
}
178+
179+
public async Task<SortedSetPopResult> SortedSetBlockingPopAsync(ValkeyKey[] keys, long count, Order order, double timeout, CommandFlags flags = CommandFlags.None)
180+
{
181+
Utils.Requires<NotImplementedException>(flags == CommandFlags.None, "Command flags are not supported by GLIDE");
182+
return await Command(Request.SortedSetBlockingPopAsync(keys, count, order, timeout));
183+
}
111184
}

sources/Valkey.Glide/Commands/Constants/Constants.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ public static class Constants
4141
public const string MinMatchLenKeyword = "MINMATCHLEN";
4242
public const string WithMatchLenKeyword = "WITHMATCHLEN";
4343

44+
/// <summary>
45+
/// Keywords for sorted set conditional operations.
46+
/// </summary>
47+
public const string ExistsKeyword = "XX";
48+
public const string NotExistsKeyword = "NX";
49+
public const string GreaterThanKeyword = "GT";
50+
public const string LessThanKeyword = "LT";
51+
52+
/// <summary>
53+
/// Keywords for sorted set operations.
54+
/// </summary>
55+
public const string WeightsKeyword = "WEIGHTS";
56+
public const string AggregateKeyword = "AGGREGATE";
57+
public const string MinKeyword = "MIN";
58+
public const string MaxKeyword = "MAX";
59+
4460
/// <summary>
4561
/// The highest bound in the sorted set for lexicographical operations.
4662
/// </summary>
@@ -60,5 +76,4 @@ public static class Constants
6076
/// The lowest bound in the sorted set for score operations.
6177
/// </summary>
6278
public const string NegativeInfinityScore = "-inf";
63-
6479
}

0 commit comments

Comments
 (0)