int do_item_replace(item *it, item *new_it) { MEMCACHED_ITEM_REPLACE(ITEM_key(it), it->nkey, it->nbytes, ITEM_key(new_it), new_it->nkey, new_it->nbytes); assert((it->it_flags & ITEM_SLABBED) == 0); do_item_unlink(it); return do_item_link(new_it); }
int do_item_replace(struct default_engine *engine, hash_item *it, hash_item *new_it) { MEMCACHED_ITEM_REPLACE(item_get_key(it), it->nkey, it->nbytes, item_get_key(new_it), new_it->nkey, new_it->nbytes); assert((it->iflag & ITEM_SLABBED) == 0); do_item_unlink(engine, it); return do_item_link(engine, new_it); }
int do_item_replace(item *it, item *new_it, const uint32_t hv) { new_it->it_flags &= ~ITEM_FAKE_MISSED; MEMCACHED_ITEM_REPLACE(ITEM_key(it), it->nkey, it->nbytes, ITEM_key(new_it), new_it->nkey, new_it->nbytes); assert((it->it_flags & ITEM_SLABBED) == 0); do_item_unlink(it, hv); return do_item_link(new_it, hv); }
//用新的item替换老的item int do_item_replace(item *it, item *new_it, const uint32_t hv) { MEMCACHED_ITEM_REPLACE(ITEM_key(it), it->nkey, it->nbytes, ITEM_key(new_it), new_it->nkey, new_it->nbytes); assert((it->it_flags & ITEM_SLABBED) == 0);//判断it是已经分配过的,如果未分配,则断言失败 do_item_unlink(it, hv);//删除原来的item return do_item_link(new_it, hv);//重新添加新的item }
int do_item_replace(item *it, item *new_it, const uint32_t hv) { syslog(LOG_INFO, "[%s:%s:%d]", __FILE__, __func__, __LINE__); MEMCACHED_ITEM_REPLACE(ITEM_key(it), it->nkey, it->nbytes, ITEM_key(new_it), new_it->nkey, new_it->nbytes); assert((it->it_flags & ITEM_SLABBED) == 0); do_item_unlink(it, hv); return do_item_link(new_it, hv); }
static void do_item_replace(struct demo_engine *engine, hash_item *it, hash_item *new_it) { MEMCACHED_ITEM_REPLACE(dm_item_get_key(it), it->nkey, it->nbytes, dm_item_get_key(new_it), new_it->nkey, new_it->nbytes); do_item_unlink(engine, it, ITEM_UNLINK_REPLACE); /* Cache item replacement does not drop the prefix item even if it's empty. * So, the below do_item_link function always return SUCCESS. */ (void)do_item_link(engine, new_it); }