-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Closed
Labels
state:needs-designthe solution is not obvious and some effort should be made to design itthe solution is not obvious and some effort should be made to design it
Milestone
Description
Hi,
In Redis, when we operate the key, we need lookupKeyWrite or lookupKeyRead, but under the multi-key command, this flag is not strict.
E.g:
void sunionDiffGenericCommand(client *c, robj **setkeys, int setnum,
robj *dstkey, int op) {
...
for (j = 0; j < setnum; j++) {
robj *setobj = dstkey ?
lookupKeyWrite(c->db,setkeys[j]) :
lookupKeyRead(c->db,setkeys[j]);
...
}
}
According to whether dstkey exists, use lookupKeyWrite or lookupKeyRead respectively, but should only use lookupKeyRead?
void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
...
/* read keys to be used for input */
src = zcalloc(sizeof(zsetopsrc) * setnum);
for (i = 0, j = 3; i < setnum; i++, j++) {
robj *obj = lookupKeyWrite(c->db,c->argv[j]);
...
}
}
Similarly, should lookupKeyRead also be used here?
If the judgment is based on the read and write attributes of the command itself, should georadius be modified to lookupKeyWrite?
{"georadius",georadiusCommand,-6,
"write @geo",
0,georadiusGetKeys,1,1,1,0,0,0},
void georadiusGeneric(client *c, int flags) {
/* Look up the requested zset */
robj *zobj = NULL;
if ((zobj = lookupKeyReadOrReply(c, key, shared.emptyarray)) == NULL || // command is "write @geo"
checkType(c, zobj, OBJ_ZSET)) {
return;
}
}
I think it should be decided according to the specific operation of this key, so the above should be changed to lookupKeyRead.
Metadata
Metadata
Assignees
Labels
state:needs-designthe solution is not obvious and some effort should be made to design itthe solution is not obvious and some effort should be made to design it