MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / insert

Method insert

src/db.cpp:2664–2692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2662}
2663
2664bool 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
2695void redisDbPersistentData::prepOverwriteForSnapshot(char *key)

Callers 15

dbAddCoreFunction · 0.45
swapdbCommandFunction · 0.45
storeKeyMethod · 0.45
startEpochMethod · 0.45
addEntryMethod · 0.45
addMethod · 0.45
registerwaitMethod · 0.45
AddTestNameFunction · 0.45
RegisterTestsMethod · 0.45
GetTestCaseMethod · 0.45

Calls 6

serverLogFunction · 0.85
dict_iterClass · 0.85
FExpiresMethod · 0.80
dictAddFunction · 0.70
dictFindFunction · 0.70

Tested by 8

AddTestNameFunction · 0.36
RegisterTestsMethod · 0.36
GetTestCaseMethod · 0.36
AddArgumentMethod · 0.36
AddArgumentsMethod · 0.36