LINDEX */
| 338 | |
| 339 | /* LINDEX <key> <index> */ |
| 340 | void lindexCommand(client *c) { |
| 341 | robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp]); |
| 342 | if (o == NULL || checkType(c,o,OBJ_LIST)) return; |
| 343 | long index; |
| 344 | |
| 345 | if ((getLongFromObjectOrReply(c, c->argv[2], &index, NULL) != C_OK)) |
| 346 | return; |
| 347 | |
| 348 | if (o->encoding == OBJ_ENCODING_QUICKLIST) { |
| 349 | quicklistEntry entry; |
| 350 | if (quicklistIndex(o->ptr, index, &entry)) { |
| 351 | if (entry.value) { |
| 352 | addReplyBulkCBuffer(c, entry.value, entry.sz); |
| 353 | } else { |
| 354 | addReplyBulkLongLong(c, entry.longval); |
| 355 | } |
| 356 | } else { |
| 357 | addReplyNull(c); |
| 358 | } |
| 359 | } else { |
| 360 | serverPanic("Unknown list encoding"); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | /* LSET <key> <index> <element> */ |
| 365 | void lsetCommand(client *c) { |
nothing calls this directly
no test coverage detected