/* Overwrite an existing key with a new value. Incrementing the reference * count of the new value is up to the caller. * This function does not modify the expire time of the existing key. * * The program is aborted if the key was not already present. */void dbOverwrite(redisDb *db, robj *key, robj *val) { dictEntry *de = dictFind(db->dict,key->ptr); serverAssertWithInfo(NULL,key,de != NULL); dictEntry auxentry = *de; robj *old = dictGetVal(de); if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) { val->lru = old->lru; } dictSetVal(db->dict, de, val); if (server.lazyfree_lazy_server_del) { /** * 异步删除旧值 */ freeObjAsync(old); /** * 将以后须要开释的旧值auxentry的值指针设置为NULL * 这样做是为了防止下一步的dictFreeVal操作执行实在的开释操作 */ dictSetVal(db->dict, &auxentry, NULL); } /** * 执行开释操作 */ dictFreeVal(db->dict, &auxentry);}