| 2662 | } |
| 2663 | |
| 2664 | bool redisDbPersistentData::insert(char *key, robj *o, bool fAssumeNew, dict_iter *piterExisting) |
| 2665 | { |
| 2666 | if (!fAssumeNew && (g_pserver->m_pstorageFactory != nullptr || m_pdbSnapshot != nullptr)) |
| 2667 | ensure(key); |
| 2668 | dictEntry *de; |
| 2669 | int res = dictAdd(m_pdict, key, o, &de); |
| 2670 | if (!FImplies(fAssumeNew, res == DICT_OK)) { |
| 2671 | serverLog(LL_WARNING, |
| 2672 | "Assumed new key %s existed in DB.", key); |
| 2673 | } |
| 2674 | if (res == DICT_OK) |
| 2675 | { |
| 2676 | #ifdef CHECKED_BUILD |
| 2677 | if (m_pdbSnapshot != nullptr && m_pdbSnapshot->find_cached_threadsafe(key) != nullptr) |
| 2678 | { |
| 2679 | serverAssert(dictFind(m_pdictTombstone, key) != nullptr); |
| 2680 | } |
| 2681 | #endif |
| 2682 | if (o->FExpires()) |
| 2683 | ++m_numexpires; |
| 2684 | trackkey(key, false /* fUpdate */); |
| 2685 | } |
| 2686 | else |
| 2687 | { |
| 2688 | if (piterExisting) |
| 2689 | *piterExisting = dict_iter(m_pdict, de); |
| 2690 | } |
| 2691 | return (res == DICT_OK); |
| 2692 | } |
| 2693 | |
| 2694 | // This is a performance tool to prevent us copying over an object we're going to overwrite anyways |
| 2695 | void redisDbPersistentData::prepOverwriteForSnapshot(char *key) |