| 670 | } |
| 671 | |
| 672 | void appendCommand(client *c) { |
| 673 | size_t totlen; |
| 674 | robj *o, *append; |
| 675 | |
| 676 | o = lookupKeyWrite(c->db,c->argv[1]); |
| 677 | if (o == NULL) { |
| 678 | /* Create the key */ |
| 679 | c->argv[2] = tryObjectEncoding(c->argv[2]); |
| 680 | dbAdd(c->db,c->argv[1],c->argv[2]); |
| 681 | incrRefCount(c->argv[2]); |
| 682 | totlen = stringObjectLen(c->argv[2]); |
| 683 | } else { |
| 684 | /* Key exists, check type */ |
| 685 | if (checkType(c,o,OBJ_STRING)) |
| 686 | return; |
| 687 | |
| 688 | /* "append" is an argument, so always an sds */ |
| 689 | append = c->argv[2]; |
| 690 | totlen = stringObjectLen(o)+sdslen(append->ptr); |
| 691 | if (checkStringLength(c,totlen) != C_OK) |
| 692 | return; |
| 693 | |
| 694 | /* Append the value */ |
| 695 | o = dbUnshareStringValue(c->db,c->argv[1],o); |
| 696 | o->ptr = sdscatlen(o->ptr,append->ptr,sdslen(append->ptr)); |
| 697 | totlen = sdslen(o->ptr); |
| 698 | } |
| 699 | signalModifiedKey(c,c->db,c->argv[1]); |
| 700 | notifyKeyspaceEvent(NOTIFY_STRING,"append",c->argv[1],c->db->id); |
| 701 | server.dirty++; |
| 702 | addReplyLongLong(c,totlen); |
| 703 | } |
| 704 | |
| 705 | void strlenCommand(client *c) { |
| 706 | robj *o; |
nothing calls this directly
no test coverage detected