-
Notifications
You must be signed in to change notification settings - Fork 531
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 BRPOPLPUSH, ZREVRANGEBYLEX deprecated commands by mapping to existing commands #769
base: main
Are you sure you want to change the base?
[Compatibility] Added BRPOPLPUSH, ZREVRANGEBYLEX deprecated commands by mapping to existing commands #769
Changes from 2 commits
0d365a6
2fea26b
40b6145
9aefc75
aef9f4d
3c41d28
f56b347
fe6af90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,6 +193,53 @@ private unsafe bool SortedSetRange<TGarnetApi>(RespCommand command, ref TGarnetA | |
return true; | ||
} | ||
|
||
/// <summary> | ||
/// ZREVRANGEBYLEX | ||
/// </summary> | ||
/// <typeparam name="TGarnetApi"></typeparam> | ||
/// <param name="storageApi"></param> | ||
/// <returns></returns> | ||
private bool ListRangeByLength<TGarnetApi>(ref TGarnetApi storageApi) | ||
where TGarnetApi : IGarnetApi | ||
{ | ||
if (parseState.Count is not (3 or 6)) | ||
{ | ||
return AbortWithWrongNumberOfArguments(nameof(RespCommand.ZREVRANGEBYLEX)); | ||
} | ||
|
||
|
||
var sbKey = parseState.GetArgSliceByRef(0); | ||
var start = parseState.GetArgSliceByRef(1); | ||
var stop = parseState.GetArgSliceByRef(2); | ||
var byLenOption = ArgSlice.FromPinnedSpan(CmdStrings.BYLEX); | ||
var revOption = ArgSlice.FromPinnedSpan(CmdStrings.REV); | ||
|
||
// ZREVRANGEBYLEX key start stop | ||
if (parseState.Count == 3) | ||
{ | ||
parseState.InitializeWithArguments(sbKey, start, stop, byLenOption, revOption); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, no need to initialize a new parse state, actually no need for this method at all, just create a new SortedSetOperation - ZREVRANGEBYLEX and call SortedSetRange directy, then handle that specific op in SortedSetObjectImpl. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
return SortedSetRange(RespCommand.ZRANGE, ref storageApi); | ||
} | ||
|
||
// ZREVRANGEBYLEX key start stop [LIMIT offset count] | ||
var limit = parseState.GetArgSliceByRef(3); | ||
var offset = parseState.GetArgSliceByRef(4); | ||
var count = parseState.GetArgSliceByRef(5); | ||
|
||
parseState.Initialize(8); | ||
parseState.SetArgument(0, sbKey); | ||
parseState.SetArgument(1, start); | ||
parseState.SetArgument(2, stop); | ||
parseState.SetArgument(3, byLenOption); | ||
parseState.SetArgument(4, revOption); | ||
parseState.SetArgument(5, limit); | ||
parseState.SetArgument(6, offset); | ||
parseState.SetArgument(7, count); | ||
|
||
return SortedSetRange(RespCommand.ZRANGE, ref storageApi); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the score of member in the sorted set at key. | ||
/// If member does not exist in the sorted set, or key does not exist, nil is returned. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why create a new parse state with the direction arguments and then call ListBlockingMove to reparse them once again? Just create the cmdArgs array and call the itemBroker directly. Alternatively, you can create a common method that takes the 5 arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will do it, I did it in this way because there are deprecated commands and the only purpose of adding these is additioning compatibility still there commands are removed as discussed in this GitHub command #684 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize these are deprecated commands. Still, it's better to have good practices throughout so that other contributors can use them as reference :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done