don't do if statement on every key for flash load, use stack object for module notify (#604)

This commit is contained in:
Malavan Sotheeswaran 2023-03-13 18:16:17 -04:00 committed by GitHub
parent 715f832b00
commit deaaa992bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2607,12 +2607,15 @@ void clusterStorageLoadCallback(const char *rgchkey, size_t cch, void *)
slotToKeyUpdateKeyCore(rgchkey, cch, true /*add*/); slotToKeyUpdateKeyCore(rgchkey, cch, true /*add*/);
} }
void moduleLoadCallback(const char * rgchKey, size_t cchKey, void *data) { void moduleLoadCallback(const char * rgchKey, size_t, void *data) {
if (g_pserver->cluster_enabled) { redisObjectStack keyobj;
initStaticStringObject(keyobj, const_cast<char *>(rgchKey));
moduleNotifyKeyspaceEvent(NOTIFY_LOADED, "loaded", &keyobj, *(int *)data);
}
void moduleClusterLoadCallback(const char * rgchKey, size_t cchKey, void *data) {
clusterStorageLoadCallback(rgchKey, cchKey, data); clusterStorageLoadCallback(rgchKey, cchKey, data);
} moduleLoadCallback(rgchKey, cchKey, data);
robj *keyobj = createEmbeddedStringObject(rgchKey, cchKey);
moduleNotifyKeyspaceEvent(NOTIFY_LOADED, "loaded", keyobj, *(int *)data);
} }
void redisDb::initialize(int id) void redisDb::initialize(int id)
@ -2633,7 +2636,7 @@ void redisDb::storageProviderInitialize()
{ {
if (g_pserver->m_pstorageFactory != nullptr) 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)); this->setStorageProvider(StorageCache::create(g_pserver->m_pstorageFactory, id, itr, &id));
} }
} }