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

Method setExpire

src/db.cpp:2753–2779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2751}
2752
2753void redisDbPersistentData::setExpire(robj *key, robj *subkey, long long when)
2754{
2755 /* Reuse the sds from the main dict in the expire dict */
2756 dictEntry *kde = dictFind(m_pdict,ptrFromObj(key));
2757 serverAssertWithInfo(NULL,key,kde != NULL);
2758 trackkey(key, true /* fUpdate */);
2759
2760 robj *o = (robj*)dictGetVal(kde);
2761 if (o->getrefcount(std::memory_order_relaxed) == OBJ_SHARED_REFCOUNT)
2762 {
2763 // shared objects cannot have the expire bit set, create a real object
2764 dictSetVal(m_pdict, kde, dupStringObject(o));
2765 o = (robj*)dictGetVal(kde);
2766 }
2767
2768 const char *szSubKey = (subkey != nullptr) ? szFromObj(subkey) : nullptr;
2769 if (o->FExpires()) {
2770 o->expire.update(szSubKey, when);
2771 }
2772 else
2773 {
2774 expireEntry e(szSubKey, when);
2775 o->expire = std::move(e);
2776 o->SetFExpires(true);
2777 ++m_numexpires;
2778 }
2779}
2780
2781void redisDbPersistentData::setExpire(const char *key, expireEntry &&e)
2782{

Callers 4

setExpireFunction · 0.45
insertMethod · 0.45
bulkInsertMethod · 0.45
flushQueuedKeysMethod · 0.45

Calls 8

ptrFromObjFunction · 0.85
dupStringObjectFunction · 0.85
szFromObjFunction · 0.85
getrefcountMethod · 0.80
FExpiresMethod · 0.80
updateMethod · 0.80
SetFExpiresMethod · 0.80
dictFindFunction · 0.70

Tested by

no test coverage detected