MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / populateCommandTable

Function populateCommandTable

src/server.cpp:4228–4248  ·  view source on GitHub ↗

Populates the KeyDB Command Table starting from the hard coded list * we have on top of server.cpp file. */

Source from the content-addressed store, hash-verified

4226/* Populates the KeyDB Command Table starting from the hard coded list
4227 * we have on top of server.cpp file. */
4228void populateCommandTable(void) {
4229 int j;
4230 int numcommands = sizeof(redisCommandTable)/sizeof(struct redisCommand);
4231
4232 for (j = 0; j < numcommands; j++) {
4233 struct redisCommand *c = redisCommandTable+j;
4234 int retval1, retval2;
4235
4236 /* Translate the command string flags description into an actual
4237 * set of flags. */
4238 if (populateCommandTableParseFlags(c,c->sflags) == C_ERR)
4239 serverPanic("Unsupported command flag");
4240
4241 c->id = ACLGetCommandID(c->name); /* Assign the ID used for ACL. */
4242 retval1 = dictAdd(g_pserver->commands, sdsnew(c->name), c);
4243 /* Populate an additional dictionary that will be unaffected
4244 * by rename-command statements in keydb.conf. */
4245 retval2 = dictAdd(g_pserver->orig_commands, sdsnew(c->name), c);
4246 serverAssert(retval1 == DICT_OK && retval2 == DICT_OK);
4247 }
4248}
4249
4250void resetCommandTableStats(void) {
4251 struct redisCommand *c;

Callers 1

initServerConfigFunction · 0.85

Calls 4

ACLGetCommandIDFunction · 0.85
sdsnewFunction · 0.85
dictAddFunction · 0.70

Tested by

no test coverage detected