| 316 | } |
| 317 | |
| 318 | void redisDb::dbOverwriteCore(redisDb::iter itr, sds keySds, robj *val, bool fUpdateMvcc, bool fRemoveExpire) |
| 319 | { |
| 320 | robj *old = itr.val(); |
| 321 | redisObjectStack keyO; |
| 322 | initStaticStringObject(keyO, keySds); |
| 323 | robj *key = &keyO; |
| 324 | |
| 325 | if (old->FExpires()) { |
| 326 | if (fRemoveExpire) { |
| 327 | ::removeExpire(this, key); |
| 328 | } |
| 329 | else { |
| 330 | if (val->getrefcount(std::memory_order_relaxed) == OBJ_SHARED_REFCOUNT) |
| 331 | val = dupStringObject(val); |
| 332 | ::updateExpire(this, itr.key(), old, val); |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | if (g_pserver->maxmemory_policy & MAXMEMORY_FLAG_LFU) { |
| 337 | val->lru = old->lru; |
| 338 | } |
| 339 | if (fUpdateMvcc) { |
| 340 | if (val->getrefcount(std::memory_order_relaxed) == OBJ_SHARED_REFCOUNT) |
| 341 | val = dupStringObject(val); |
| 342 | setMvccTstamp(val, getMvccTstamp()); |
| 343 | } |
| 344 | |
| 345 | /* Although the key is not really deleted from the database, we regard |
| 346 | overwrite as two steps of unlink+add, so we still need to call the unlink |
| 347 | callback of the module. */ |
| 348 | moduleNotifyKeyUnlink(key,old); |
| 349 | |
| 350 | if (g_pserver->lazyfree_lazy_server_del) |
| 351 | freeObjAsync(key, itr.val()); |
| 352 | else |
| 353 | decrRefCount(itr.val()); |
| 354 | |
| 355 | updateValue(itr, val); |
| 356 | } |
| 357 | |
| 358 | /* Overwrite an existing key with a new value. Incrementing the reference |
| 359 | * count of the new value is up to the caller. |
no test coverage detected