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

Function nhgetCommand

src/t_nhash.cpp:367–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365}
366
367void nhgetCommand(client *c) {
368 if (c->argc != 2 && c->argc != 3)
369 throw shared.syntaxerr;
370
371 bool fJson = false;
372 int argOffset = 0;
373 if (c->argc == 3) {
374 argOffset++;
375 if (strcasecmp(szFromObj(c->argv[1]), "json") == 0) {
376 fJson = true;
377 } else if (strcasecmp(szFromObj(c->argv[1]), "resp") != 0) {
378 throw shared.syntaxerr;
379 }
380 }
381
382 robj *o = fetchFromKey(c->db, c->argv[argOffset + 1]);
383 if (fJson) {
384 sds val = writeNestedHashAsJson(sdsnew(nullptr), o);
385 addReplyBulkSds(c, val);
386 } else {
387 writeNestedHashToClient(c, o);
388 }
389}

Callers

nothing calls this directly

Calls 6

szFromObjFunction · 0.85
fetchFromKeyFunction · 0.85
writeNestedHashAsJsonFunction · 0.85
sdsnewFunction · 0.85
addReplyBulkSdsFunction · 0.85
writeNestedHashToClientFunction · 0.85

Tested by

no test coverage detected