Implement keydb.hrename command
Former-commit-id: 21d842b0b0d9a0da44e4618a2c1d4ac26553f17b
This commit is contained in:
parent
e28d3b33c7
commit
e9ecefdb75
@ -1042,6 +1042,10 @@ struct redisCommand redisCommandTable[] = {
|
|||||||
{"keydb.cron",cronCommand,-5,
|
{"keydb.cron",cronCommand,-5,
|
||||||
"write use-memory",
|
"write use-memory",
|
||||||
0,NULL,1,1,1,0,0,0},
|
0,NULL,1,1,1,0,0,0},
|
||||||
|
|
||||||
|
{"keydb.hrename", hrenameCommand, 4,
|
||||||
|
"write fast @hash",
|
||||||
|
0,NULL,0,0,0,0,0,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*============================ Utility functions ============================ */
|
/*============================ Utility functions ============================ */
|
||||||
|
@ -2966,6 +2966,7 @@ void xdelCommand(client *c);
|
|||||||
void xtrimCommand(client *c);
|
void xtrimCommand(client *c);
|
||||||
void aclCommand(client *c);
|
void aclCommand(client *c);
|
||||||
void replicaReplayCommand(client *c);
|
void replicaReplayCommand(client *c);
|
||||||
|
void hrenameCommand(client *c);
|
||||||
|
|
||||||
int FBrokenLinkToMaster();
|
int FBrokenLinkToMaster();
|
||||||
int FActiveMaster(client *c);
|
int FActiveMaster(client *c);
|
||||||
|
@ -832,3 +832,33 @@ void hscanCommand(client *c) {
|
|||||||
checkType(c,o,OBJ_HASH)) return;
|
checkType(c,o,OBJ_HASH)) return;
|
||||||
scanGenericCommand(c,o,cursor);
|
scanGenericCommand(c,o,cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hrenameCommand(client *c) {
|
||||||
|
robj *o = nullptr;
|
||||||
|
const unsigned char *vstr;
|
||||||
|
unsigned int vlen;
|
||||||
|
long long ll;
|
||||||
|
|
||||||
|
if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.null[c->resp])) == nullptr ||
|
||||||
|
checkType(c,o,OBJ_HASH)) return;
|
||||||
|
|
||||||
|
if (hashTypeGetValue(o, szFromObj(c->argv[2]), &vstr, &vlen, &ll) != C_OK)
|
||||||
|
{
|
||||||
|
addReplyError(c, "hash key doesn't exist");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sds sdsT = nullptr;
|
||||||
|
if (vstr != nullptr)
|
||||||
|
{
|
||||||
|
sdsT = sdsnewlen(vstr, vlen);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sdsT = sdsfromlonglong(ll);
|
||||||
|
}
|
||||||
|
|
||||||
|
hashTypeDelete(o, szFromObj(c->argv[2]));
|
||||||
|
hashTypeSet(o, szFromObj(c->argv[3]), sdsT, HASH_SET_TAKE_VALUE);
|
||||||
|
addReplyLongLong(c, 1);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user