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

Function hrenameCommand

src/t_hash.cpp:969–997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

967}
968
969void hrenameCommand(client *c) {
970 robj *o = nullptr;
971 const unsigned char *vstr;
972 unsigned int vlen;
973 long long ll;
974
975 if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.null[c->resp])) == nullptr ||
976 checkType(c,o,OBJ_HASH)) return;
977
978 if (hashTypeGetValue(o, szFromObj(c->argv[2]), &vstr, &vlen, &ll) != C_OK)
979 {
980 addReplyError(c, "hash key doesn't exist");
981 return;
982 }
983
984 sds sdsT = nullptr;
985 if (vstr != nullptr)
986 {
987 sdsT = sdsnewlen(vstr, vlen);
988 }
989 else
990 {
991 sdsT = sdsfromlonglong(ll);
992 }
993
994 hashTypeDelete(o, szFromObj(c->argv[2]));
995 hashTypeSet(o, szFromObj(c->argv[3]), sdsT, HASH_SET_TAKE_VALUE);
996 addReplyLongLong(c, 1);
997}
998
999static void harndfieldReplyWithZiplist(client *c, unsigned int count, ziplistEntry *keys, ziplistEntry *vals) {
1000 for (unsigned long i = 0; i < count; i++) {

Callers

nothing calls this directly

Calls 10

lookupKeyWriteOrReplyFunction · 0.85
checkTypeFunction · 0.85
hashTypeGetValueFunction · 0.85
szFromObjFunction · 0.85
addReplyErrorFunction · 0.85
sdsnewlenFunction · 0.85
sdsfromlonglongFunction · 0.85
hashTypeDeleteFunction · 0.85
hashTypeSetFunction · 0.85
addReplyLongLongFunction · 0.85

Tested by

no test coverage detected