Update comments on command args, and a misleading error reply (#10645)
Updated the comments for: info command lmpopCommand and blmpopCommand sinterGenericCommand Fix the missing "key" words in the srandmemberCommand function For LPOS command, when rank is 0, prompt user that rank could be positive number or negative number, and add a test for it
This commit is contained in:
parent
586a16ad79
commit
135998ed8d
|
@ -4127,7 +4127,7 @@ numargserr:
|
|||
|
||||
void addInfoSectionsToDict(dict *section_dict, char **sections);
|
||||
|
||||
/* SENTINEL INFO [section] */
|
||||
/* INFO [<section> [<section> ...]] */
|
||||
void sentinelInfoCommand(client *c) {
|
||||
char *sentinel_sections[] = {"server", "clients", "cpu", "stats", "sentinel", NULL};
|
||||
int sec_all = 0, sec_everything = 0;
|
||||
|
|
|
@ -5917,6 +5917,7 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
|
|||
return info;
|
||||
}
|
||||
|
||||
/* INFO [<section> [<section> ...]] */
|
||||
void infoCommand(client *c) {
|
||||
if (server.sentinel_mode) {
|
||||
sentinelInfoCommand(c);
|
||||
|
|
|
@ -679,7 +679,8 @@ void lposCommand(client *c) {
|
|||
return;
|
||||
if (rank == 0) {
|
||||
addReplyError(c,"RANK can't be zero: use 1 to start from "
|
||||
"the first match, 2 from the second, ...");
|
||||
"the first match, 2 from the second ... "
|
||||
"or use negative to start from the end of the list");
|
||||
return;
|
||||
}
|
||||
} else if (!strcasecmp(opt,"COUNT") && moreargs) {
|
||||
|
@ -1197,12 +1198,12 @@ void lmpopGenericCommand(client *c, int numkeys_idx, int is_block) {
|
|||
}
|
||||
}
|
||||
|
||||
/* LMPOP numkeys [<key> ...] LEFT|RIGHT [COUNT count] */
|
||||
/* LMPOP numkeys <key> [<key> ...] (LEFT|RIGHT) [COUNT count] */
|
||||
void lmpopCommand(client *c) {
|
||||
lmpopGenericCommand(c, 1, 0);
|
||||
}
|
||||
|
||||
/* BLMPOP timeout numkeys [<key> ...] LEFT|RIGHT [COUNT count] */
|
||||
/* BLMPOP timeout numkeys <key> [<key> ...] (LEFT|RIGHT) [COUNT count] */
|
||||
void blmpopCommand(client *c) {
|
||||
lmpopGenericCommand(c, 2, 1);
|
||||
}
|
||||
|
|
|
@ -805,7 +805,7 @@ void srandmemberWithCountCommand(client *c) {
|
|||
}
|
||||
}
|
||||
|
||||
/* SRANDMEMBER [<count>] */
|
||||
/* SRANDMEMBER <key> [<count>] */
|
||||
void srandmemberCommand(client *c) {
|
||||
robj *set;
|
||||
sds ele;
|
||||
|
@ -850,7 +850,7 @@ int qsortCompareSetsByRevCardinality(const void *s1, const void *s2) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* SINTER / SINTERSTORE / SINTERCARD
|
||||
/* SINTER / SMEMBERS / SINTERSTORE / SINTERCARD
|
||||
*
|
||||
* 'cardinality_only' work for SINTERCARD, only return the cardinality
|
||||
* with minimum processing and memory overheads.
|
||||
|
|
|
@ -389,12 +389,13 @@ start_server {
|
|||
assert {[r LPOS mylist c] == 2}
|
||||
}
|
||||
|
||||
test {LPOS RANK (positive and negative rank) option} {
|
||||
test {LPOS RANK (positive, negative and zero rank) option} {
|
||||
assert {[r LPOS mylist c RANK 1] == 2}
|
||||
assert {[r LPOS mylist c RANK 2] == 6}
|
||||
assert {[r LPOS mylist c RANK 4] eq ""}
|
||||
assert {[r LPOS mylist c RANK -1] == 7}
|
||||
assert {[r LPOS mylist c RANK -2] == 6}
|
||||
assert_error "*RANK can't be zero: use 1 to start from the first match, 2 from the second ... or use negative to start*" {r LPOS mylist c RANK 0}
|
||||
}
|
||||
|
||||
test {LPOS COUNT option} {
|
||||
|
|
Loading…
Reference in New Issue