| 336 | } |
| 337 | |
| 338 | void nhsetCommand(client *c) { |
| 339 | if (c->argc < 3) |
| 340 | throw shared.syntaxerr; |
| 341 | |
| 342 | robj *val = c->argv[2]; |
| 343 | if (c->argc > 3) { |
| 344 | // Its a list, we'll store as a ziplist |
| 345 | val = createZiplistObject(); |
| 346 | for (int iarg = 2; iarg < c->argc; ++iarg) { |
| 347 | sds arg = (sds)szFromObj(c->argv[iarg]); |
| 348 | val->m_ptr = ziplistPush((unsigned char*)ptrFromObj(val), (unsigned char*)arg, sdslen(arg), ZIPLIST_TAIL); |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | try { |
| 353 | if (setWithKey(c->db, c->argv[1], val, true)) { |
| 354 | addReplyLongLong(c, 1); // we replaced a value |
| 355 | } else { |
| 356 | addReplyLongLong(c, 0); // we added a new value |
| 357 | } |
| 358 | } catch (...) { |
| 359 | if (val != c->argv[2]) |
| 360 | decrRefCount(val); |
| 361 | throw; |
| 362 | } |
| 363 | if (val != c->argv[2]) |
| 364 | decrRefCount(val); |
| 365 | } |
| 366 | |
| 367 | void nhgetCommand(client *c) { |
| 368 | if (c->argc != 2 && c->argc != 3) |
nothing calls this directly
no test coverage detected