Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
caf7b9b4
Commit
caf7b9b4
authored
Mar 10, 2014
by
antirez
Browse files
Cluster: getKeysFromCommand() and related: top-comments added.
parent
787b2970
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
caf7b9b4
...
...
@@ -930,6 +930,8 @@ void persistCommand(redisClient *c) {
* API to get key arguments from commands
* ---------------------------------------------------------------------------*/
/* The base case is to use the keys position as given in the command table
* (firstkey, lastkey, step). */
int
*
getKeysUsingCommandTable
(
struct
redisCommand
*
cmd
,
robj
**
argv
,
int
argc
,
int
*
numkeys
)
{
int
j
,
i
=
0
,
last
,
*
keys
;
REDIS_NOTUSED
(
argv
);
...
...
@@ -949,6 +951,11 @@ int *getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, in
return
keys
;
}
/* Return keys as an heap allocated array of integers. The length of the array
* is returned by reference into *numkeys.
*
* This function uses the command table if a command-specific helper function
* is not required, otherwise it calls the command-specific function. */
int
*
getKeysFromCommand
(
struct
redisCommand
*
cmd
,
robj
**
argv
,
int
argc
,
int
*
numkeys
)
{
if
(
cmd
->
getkeys_proc
)
{
return
cmd
->
getkeys_proc
(
cmd
,
argv
,
argc
,
numkeys
);
...
...
@@ -957,11 +964,15 @@ int *getKeysFromCommand(struct redisCommand *cmd,robj **argv, int argc, int *num
}
}
/* Free the result of getKeysFromCommand. */
void
getKeysFreeResult
(
int
*
result
)
{
zfree
(
result
);
}
int
*
zunionInterGetKeys
(
struct
redisCommand
*
cmd
,
robj
**
argv
,
int
argc
,
int
*
numkeys
)
{
/* Helper function to extract keys from following commands:
* ZUNIONSTORE <destkey> <num-keys> <key> <key> ... <key> <options>
* ZINTERSTORE <destkey> <num-keys> <key> <key> ... <key> <options> */
int
*
zunionInterGetKeys
(
struct
redisCommand
*
cmd
,
robj
**
argv
,
int
argc
,
int
*
numkeys
)
{
int
i
,
num
,
*
keys
;
REDIS_NOTUSED
(
cmd
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment