LSET */
| 363 | |
| 364 | /* LSET <key> <index> <element> */ |
| 365 | void lsetCommand(client *c) { |
| 366 | robj *o = lookupKeyWriteOrReply(c,c->argv[1],shared.nokeyerr); |
| 367 | if (o == NULL || checkType(c,o,OBJ_LIST)) return; |
| 368 | long index; |
| 369 | robj *value = c->argv[3]; |
| 370 | |
| 371 | if (sdslen(value->ptr) > LIST_MAX_ITEM_SIZE) { |
| 372 | addReplyError(c, "Element too large"); |
| 373 | return; |
| 374 | } |
| 375 | |
| 376 | if ((getLongFromObjectOrReply(c, c->argv[2], &index, NULL) != C_OK)) |
| 377 | return; |
| 378 | |
| 379 | if (o->encoding == OBJ_ENCODING_QUICKLIST) { |
| 380 | quicklist *ql = o->ptr; |
| 381 | int replaced = quicklistReplaceAtIndex(ql, index, |
| 382 | value->ptr, sdslen(value->ptr)); |
| 383 | if (!replaced) { |
| 384 | addReplyErrorObject(c,shared.outofrangeerr); |
| 385 | } else { |
| 386 | addReply(c,shared.ok); |
| 387 | signalModifiedKey(c,c->db,c->argv[1]); |
| 388 | notifyKeyspaceEvent(NOTIFY_LIST,"lset",c->argv[1],c->db->id); |
| 389 | server.dirty++; |
| 390 | } |
| 391 | } else { |
| 392 | serverPanic("Unknown list encoding"); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | /* A helper for replying with a list's range between the inclusive start and end |
| 397 | * indexes as multi-bulk, with support for negative indexes. Note that start |
nothing calls this directly
no test coverage detected