Merge DEL queries into one query

refs #4991
This commit is contained in:
Gunnar Beutner 2017-03-16 15:05:44 +01:00
parent 00eba25ad7
commit 62c1a64788
1 changed files with 7 additions and 27 deletions

View File

@ -65,45 +65,25 @@ void RedisWriter::UpdateAllConfigObjects(void)
String typeName = type->GetName(); String typeName = type->GetName();
/* replace into aka delete insert is faster than a full diff */ /* replace into aka delete insert is faster than a full diff */
redisReply *reply1 = reinterpret_cast<redisReply *>(redisCommand(m_Context, "DEL icinga:config:%s", typeName.CStr())); redisReply *reply = reinterpret_cast<redisReply *>(redisCommand(m_Context, "DEL icinga:config:%s icinga:status:%s", typeName.CStr(), typeName.CStr()));
if (!reply1) { if (!reply) {
redisFree(m_Context); redisFree(m_Context);
m_Context = NULL; m_Context = NULL;
return; return;
} }
if (reply1->type == REDIS_REPLY_STATUS || reply1->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_STATUS || reply->type == REDIS_REPLY_ERROR) {
Log(LogInformation, "RedisWriter") Log(LogInformation, "RedisWriter")
<< "DEL icinga:config:" << typeName << ": " << reply1->str; << "DEL icinga:config:" << typeName << ": " << reply->str;
} }
if (reply1->type == REDIS_REPLY_ERROR) { if (reply->type == REDIS_REPLY_ERROR) {
freeReplyObject(reply1); freeReplyObject(reply);
return; return;
} }
freeReplyObject(reply1); freeReplyObject(reply);
redisReply *reply2 = reinterpret_cast<redisReply *>(redisCommand(m_Context, "DEL icinga:status:%s", typeName.CStr()));
if (!reply2) {
redisFree(m_Context);
m_Context = NULL;
return;
}
if (reply2->type == REDIS_REPLY_STATUS || reply2->type == REDIS_REPLY_ERROR) {
Log(LogInformation, "RedisWriter")
<< "DEL icinga:status:" << typeName << ": " << reply2->str;
}
if (reply2->type == REDIS_REPLY_ERROR) {
freeReplyObject(reply2);
return;
}
freeReplyObject(reply2);
/* fetch all objects and dump them */ /* fetch all objects and dump them */
ConfigType *ctype = dynamic_cast<ConfigType *>(type.get()); ConfigType *ctype = dynamic_cast<ConfigType *>(type.get());