Prepare the string object stored at 'key' to be modified destructively * to implement commands like SETBIT or APPEND. * * An object is usually ready to be modified unless one of the two conditions * are true: * * 1) The object 'o' is shared (refcount > 1), we don't want to affect * other users. * 2) The object encoding is not "RAW". * * If the object is found in one of the above condi
| 553 | * using an sdscat() call to append some data, or anything else. |
| 554 | */ |
| 555 | robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o) { |
| 556 | serverAssert(o->type == OBJ_STRING); |
| 557 | if (o->getrefcount(std::memory_order_relaxed) != 1 || o->encoding != OBJ_ENCODING_RAW) { |
| 558 | robj *decoded = getDecodedObject(o); |
| 559 | o = createRawStringObject(szFromObj(decoded), sdslen(szFromObj(decoded))); |
| 560 | decrRefCount(decoded); |
| 561 | dbOverwrite(db,key,o); |
| 562 | } |
| 563 | return o; |
| 564 | } |
| 565 | |
| 566 | /* Remove all keys from the database(s) structure. The dbarray argument |
| 567 | * may not be the server main DBs (could be a backup). |
no test coverage detected