Add dedicated sunioncardGetKeys for SUNIONCARD command

Replace the reuse of sintercardGetKeys with a dedicated
sunioncardGetKeys function for naming clarity, following the codebase
convention where each command family has its own get_keys_function
even when the underlying genericGetKeys call is identical.
This commit is contained in:
Hristo Staykov 2026-03-20 12:12:11 +02:00
parent e2cc2b3e09
commit 73add45faf
4 changed files with 8 additions and 2 deletions

View file

@ -12585,7 +12585,7 @@ struct COMMAND_STRUCT redisCommandTable[] = {
{MAKE_CMD("srem","Removes one or more members from a set. Deletes the set if the last member was removed.","O(N) where N is the number of members to be removed.","1.0.0",CMD_DOC_NONE,NULL,NULL,"set",COMMAND_GROUP_SET,SREM_History,1,SREM_Tips,0,sremCommand,-3,CMD_WRITE|CMD_FAST,ACL_CATEGORY_SET,SREM_Keyspecs,1,NULL,2),.args=SREM_Args},
{MAKE_CMD("sscan","Iterates over members of a set.","O(1) for every call. O(N) for a complete iteration, including enough command calls for the cursor to return back to 0. N is the number of elements inside the collection.","2.8.0",CMD_DOC_NONE,NULL,NULL,"set",COMMAND_GROUP_SET,SSCAN_History,0,SSCAN_Tips,1,sscanCommand,-3,CMD_READONLY,ACL_CATEGORY_SET,SSCAN_Keyspecs,1,NULL,4),.args=SSCAN_Args},
{MAKE_CMD("sunion","Returns the union of multiple sets.","O(N) where N is the total number of elements in all given sets.","1.0.0",CMD_DOC_NONE,NULL,NULL,"set",COMMAND_GROUP_SET,SUNION_History,0,SUNION_Tips,1,sunionCommand,-2,CMD_READONLY,ACL_CATEGORY_SET,SUNION_Keyspecs,1,NULL,1),.args=SUNION_Args},
{MAKE_CMD("sunioncard","Returns the number of members of the union of multiple sets.","O(N) where N is the total number of elements in all given sets.","8.8.0",CMD_DOC_NONE,NULL,NULL,"set",COMMAND_GROUP_SET,SUNIONCARD_History,0,SUNIONCARD_Tips,0,sunioncardCommand,-3,CMD_READONLY,ACL_CATEGORY_SET,SUNIONCARD_Keyspecs,1,sintercardGetKeys,4),.args=SUNIONCARD_Args},
{MAKE_CMD("sunioncard","Returns the number of members of the union of multiple sets.","O(N) where N is the total number of elements in all given sets.","8.8.0",CMD_DOC_NONE,NULL,NULL,"set",COMMAND_GROUP_SET,SUNIONCARD_History,0,SUNIONCARD_Tips,0,sunioncardCommand,-3,CMD_READONLY,ACL_CATEGORY_SET,SUNIONCARD_Keyspecs,1,sunioncardGetKeys,4),.args=SUNIONCARD_Args},
{MAKE_CMD("sunionstore","Stores the union of multiple sets in a key.","O(N) where N is the total number of elements in all given sets.","1.0.0",CMD_DOC_NONE,NULL,NULL,"set",COMMAND_GROUP_SET,SUNIONSTORE_History,0,SUNIONSTORE_Tips,0,sunionstoreCommand,-3,CMD_WRITE|CMD_DENYOOM,ACL_CATEGORY_SET,SUNIONSTORE_Keyspecs,2,NULL,2),.args=SUNIONSTORE_Args},
/* sorted_set */
{MAKE_CMD("bzmpop","Removes and returns a member by score from one or more sorted sets. Blocks until a member is available otherwise. Deletes the sorted set if the last element was popped.","O(K) + O(M*log(N)) where K is the number of provided keys, N being the number of elements in the sorted set, and M being the number of elements popped.","7.0.0",CMD_DOC_NONE,NULL,NULL,"sorted_set",COMMAND_GROUP_SORTED_SET,BZMPOP_History,0,BZMPOP_Tips,0,bzmpopCommand,-5,CMD_WRITE|CMD_BLOCKING,ACL_CATEGORY_SORTEDSET,BZMPOP_Keyspecs,1,blmpopGetKeys,5),.args=BZMPOP_Args},

View file

@ -6,7 +6,7 @@
"since": "8.8.0",
"arity": -3,
"function": "sunioncardCommand",
"get_keys_function": "sintercardGetKeys",
"get_keys_function": "sunioncardGetKeys",
"command_flags": [
"READONLY"
],

View file

@ -3560,6 +3560,11 @@ int sintercardGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysRe
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
}
int sunioncardGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
UNUSED(cmd);
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
}
int zunionInterDiffStoreGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
UNUSED(cmd);
return genericGetKeys(1, 2, 3, 1, argv, argc, result);

View file

@ -4099,6 +4099,7 @@ int doesCommandHaveChannelsWithFlags(struct redisCommand *cmd, int flags);
void getKeysFreeResult(getKeysResult *result);
int extractKeysAndSlot(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result, int *slot);
int sintercardGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result);
int sunioncardGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result);
int zunionInterDiffGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result);
int zunionInterDiffStoreGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result);
int evalGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);