redis cluster keys command implementation

redis entire db dictionary is a hash table (not supported range lookup), so that the command keys need to traverse db in all key it? ? Long years ago slag keen to use xxx_yyy_zzz_ * way to match the key, and why they are keen to do so, is not it redis special optimization techniques it? With these questions have downloaded the latest version of Redis code.

aims:

1. Locate the keys implementations, really low performance. --done

The reason keys to other hosts in the cluster 2. Position redis-cluster where the host is not distributed. --done

3. Locate a spring-cloud + redis cluster paradigm keys execute the command. --Unverified

 

Command keys do need to traverse the entire database, as detailed db.c :: keysCommand

1. Server start-up phase, server.c :: initServerConfig () call populateCommandTable load command list;

 

 

redis The following is a list of commands supported hard coded, can see the command processing logic function keys (keysCommand) that, through all the key database.

 

struct redisCommand redisCommandTable[] = {
    {"module",moduleCommand,-2,"as",0,NULL,0,0,0,0,0},
    {"get",getCommand,2,"rF",0,NULL,1,1,1,0,0},
    {"set",setCommand,-3,"wm",0,NULL,1,1,1,0,0},
    //...
    {"keys",keysCommand,2,"rS",0,NULL,0,0,0,0,0},
    //...
};

 

 

 

Command keys with no key, and redis not define rollup logical query result of each node, it is not the route command keys. For details, see server.c :: processCommand ()

 

 

 

 

  

Some learn to use keys posture and self-conceived keys using gestures

Method One: aaa: bbb: ccc: ddd entire existence of such a hash table key, uniform data distribution is what?

Method two: each cluster node to execute the command keys, summarizes the results.

Method three: to maintain their own "Index." For example in the use of key redis years as aaa: bbb: ccc hash table to store all aaa: bbb: ccc: * Such key.

summary

1. keys command by traversing the entire db key refiltered achieved.

2. keys command will not be routed to another cluster node cluster, cluster keys will not return the results of each node summary results.

Guess you like

Origin www.cnblogs.com/yinkw/p/redis_keys.html