From deaaa992bd629f1b633a73004ba3ee97d23b18e1 Mon Sep 17 00:00:00 2001 From: Malavan Sotheeswaran <105669860+msotheeswaran@users.noreply.github.com> Date: Mon, 13 Mar 2023 18:16:17 -0400 Subject: [PATCH] don't do if statement on every key for flash load, use stack object for module notify (#604) --- src/db.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/db.cpp b/src/db.cpp index 0c6dc5e8a..21d00ad10 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -2607,12 +2607,15 @@ void clusterStorageLoadCallback(const char *rgchkey, size_t cch, void *) slotToKeyUpdateKeyCore(rgchkey, cch, true /*add*/); } -void moduleLoadCallback(const char * rgchKey, size_t cchKey, void *data) { - if (g_pserver->cluster_enabled) { - clusterStorageLoadCallback(rgchKey, cchKey, data); - } - robj *keyobj = createEmbeddedStringObject(rgchKey, cchKey); - moduleNotifyKeyspaceEvent(NOTIFY_LOADED, "loaded", keyobj, *(int *)data); +void moduleLoadCallback(const char * rgchKey, size_t, void *data) { + redisObjectStack keyobj; + initStaticStringObject(keyobj, const_cast(rgchKey)); + moduleNotifyKeyspaceEvent(NOTIFY_LOADED, "loaded", &keyobj, *(int *)data); +} + +void moduleClusterLoadCallback(const char * rgchKey, size_t cchKey, void *data) { + clusterStorageLoadCallback(rgchKey, cchKey, data); + moduleLoadCallback(rgchKey, cchKey, data); } void redisDb::initialize(int id) @@ -2633,7 +2636,7 @@ void redisDb::storageProviderInitialize() { if (g_pserver->m_pstorageFactory != nullptr) { - IStorageFactory::key_load_iterator itr = moduleLoadCallback; + IStorageFactory::key_load_iterator itr = g_pserver->cluster_enabled ? moduleClusterLoadCallback : moduleLoadCallback; this->setStorageProvider(StorageCache::create(g_pserver->m_pstorageFactory, id, itr, &id)); } }