Permalink
Browse files

Cluster: getKeysFromCommand() API cleaned up.

This API originated from the "diskstore" experiment, not for Redis
Cluster itself, so there were legacy/useless things trying to
differentiate between keys that are going to be overwritten and keys
that need to be fetched from disk (preloaded).

All useless with Cluster, so removed with the result of code
simplification.
  • Loading branch information...
1 parent 55b88e0 commit 787b297046b5695c5dbca87060566cf1d93762de @antirez committed Mar 10, 2014
Showing with 15 additions and 41 deletions.
  1. +1 −2 src/cluster.c
  2. +3 −24 src/db.c
  3. +8 −8 src/redis.c
  4. +3 −7 src/redis.h
View
3 src/cluster.c
@@ -3897,8 +3897,7 @@ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **arg
margc = ms->commands[i].argc;
margv = ms->commands[i].argv;
- keyindex = getKeysFromCommand(mcmd,margv,margc,&numkeys,
- REDIS_GETKEYS_ALL);
+ keyindex = getKeysFromCommand(mcmd,margv,margc,&numkeys);
for (j = 0; j < numkeys; j++) {
robj *thiskey = margv[keyindex[j]];
int thisslot = keyHashSlot((char*)thiskey->ptr,
View
27 src/db.c
@@ -949,9 +949,9 @@ int *getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, in
return keys;
}
-int *getKeysFromCommand(struct redisCommand *cmd,robj **argv, int argc, int *numkeys, int flags) {
+int *getKeysFromCommand(struct redisCommand *cmd,robj **argv, int argc, int *numkeys) {
if (cmd->getkeys_proc) {
- return cmd->getkeys_proc(cmd,argv,argc,numkeys,flags);
+ return cmd->getkeys_proc(cmd,argv,argc,numkeys);
} else {
return getKeysUsingCommandTable(cmd,argv,argc,numkeys);
}
@@ -961,30 +961,9 @@ void getKeysFreeResult(int *result) {
zfree(result);
}
-int *noPreloadGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *numkeys, int flags) {
- if (flags & REDIS_GETKEYS_PRELOAD) {
- *numkeys = 0;
- return NULL;
- } else {
- return getKeysUsingCommandTable(cmd,argv,argc,numkeys);
- }
-}
-
-int *renameGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *numkeys, int flags) {
- if (flags & REDIS_GETKEYS_PRELOAD) {
- int *keys = zmalloc(sizeof(int));
- *numkeys = 1;
- keys[0] = 1;
- return keys;
- } else {
- return getKeysUsingCommandTable(cmd,argv,argc,numkeys);
- }
-}
-
-int *zunionInterGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *numkeys, int flags) {
+int *zunionInterGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *numkeys) {
int i, num, *keys;
REDIS_NOTUSED(cmd);
- REDIS_NOTUSED(flags);
num = atoi(argv[2]->ptr);
/* Sanity check. Don't return any key if the command is going to
View
16 src/redis.c
@@ -118,13 +118,13 @@ struct redisCommand *commandTable;
*/
struct redisCommand redisCommandTable[] = {
{"get",getCommand,2,"r",0,NULL,1,1,1,0,0},
- {"set",setCommand,-3,"wm",0,noPreloadGetKeys,1,1,1,0,0},
- {"setnx",setnxCommand,3,"wm",0,noPreloadGetKeys,1,1,1,0,0},
- {"setex",setexCommand,4,"wm",0,noPreloadGetKeys,1,1,1,0,0},
- {"psetex",psetexCommand,4,"wm",0,noPreloadGetKeys,1,1,1,0,0},
+ {"set",setCommand,-3,"wm",0,NULL,1,1,1,0,0},
+ {"setnx",setnxCommand,3,"wm",0,NULL,1,1,1,0,0},
+ {"setex",setexCommand,4,"wm",0,NULL,1,1,1,0,0},
+ {"psetex",psetexCommand,4,"wm",0,NULL,1,1,1,0,0},
{"append",appendCommand,3,"wm",0,NULL,1,1,1,0,0},
{"strlen",strlenCommand,2,"r",0,NULL,1,1,1,0,0},
- {"del",delCommand,-2,"w",0,noPreloadGetKeys,1,-1,1,0,0},
+ {"del",delCommand,-2,"w",0,NULL,1,-1,1,0,0},
{"exists",existsCommand,2,"r",0,NULL,1,1,1,0,0},
{"setbit",setbitCommand,4,"wm",0,NULL,1,1,1,0,0},
{"getbit",getbitCommand,3,"r",0,NULL,1,1,1,0,0},
@@ -206,8 +206,8 @@ struct redisCommand redisCommandTable[] = {
{"randomkey",randomkeyCommand,1,"rR",0,NULL,0,0,0,0,0},
{"select",selectCommand,2,"rl",0,NULL,0,0,0,0,0},
{"move",moveCommand,3,"w",0,NULL,1,1,1,0,0},
- {"rename",renameCommand,3,"w",0,renameGetKeys,1,2,1,0,0},
- {"renamenx",renamenxCommand,3,"w",0,renameGetKeys,1,2,1,0,0},
+ {"rename",renameCommand,3,"w",0,NULL,1,2,1,0,0},
+ {"renamenx",renamenxCommand,3,"w",0,NULL,1,2,1,0,0},
{"expire",expireCommand,3,"w",0,NULL,1,1,1,0,0},
{"expireat",expireatCommand,3,"w",0,NULL,1,1,1,0,0},
{"pexpire",pexpireCommand,3,"w",0,NULL,1,1,1,0,0},
@@ -247,7 +247,7 @@ struct redisCommand redisCommandTable[] = {
{"punsubscribe",punsubscribeCommand,-1,"rpslt",0,NULL,0,0,0,0,0},
{"publish",publishCommand,3,"pltr",0,NULL,0,0,0,0,0},
{"pubsub",pubsubCommand,-2,"pltrR",0,NULL,0,0,0,0,0},
- {"watch",watchCommand,-2,"rs",0,noPreloadGetKeys,1,-1,1,0,0},
+ {"watch",watchCommand,-2,"rs",0,NULL,1,-1,1,0,0},
{"unwatch",unwatchCommand,1,"rs",0,NULL,0,0,0,0,0},
{"cluster",clusterCommand,-2,"ar",0,NULL,0,0,0,0,0},
{"restore",restoreCommand,-4,"awm",0,NULL,1,1,1,0,0},
View
10 src/redis.h
@@ -826,7 +826,7 @@ typedef struct pubsubPattern {
} pubsubPattern;
typedef void redisCommandProc(redisClient *c);
-typedef int *redisGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, int *numkeys, int flags);
+typedef int *redisGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, int *numkeys);
struct redisCommand {
char *name;
redisCommandProc *proc;
@@ -1237,13 +1237,9 @@ void scanGenericCommand(redisClient *c, robj *o, unsigned long cursor);
int parseScanCursorOrReply(redisClient *c, robj *o, unsigned long *cursor);
/* API to get key arguments from commands */
-#define REDIS_GETKEYS_ALL 0
-#define REDIS_GETKEYS_PRELOAD 1
-int *getKeysFromCommand(struct redisCommand *cmd, robj **argv, int argc, int *numkeys, int flags);
+int *getKeysFromCommand(struct redisCommand *cmd, robj **argv, int argc, int *numkeys);
void getKeysFreeResult(int *result);
-int *noPreloadGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *numkeys, int flags);
-int *renameGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *numkeys, int flags);
-int *zunionInterGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *numkeys, int flags);
+int *zunionInterGetKeys(struct redisCommand *cmd,robj **argv, int argc, int *numkeys);
/* Cluster */
void clusterInit(void);

0 comments on commit 787b297

Please sign in to comment.