简单ttl懒删除支持
This commit is contained in:
@@ -60,6 +60,7 @@ static void set_default_config(AppConfig *cfg)
|
||||
cfg->allocator = ALLOC_JEMALLOC;
|
||||
cfg->leak_mode = MEMLEAK_DETECT_OFF;
|
||||
cfg->replica_mode = REPLICA_DISABLE;
|
||||
cfg->redis_auth_password[0] = '\0';
|
||||
}
|
||||
|
||||
/* ---- 字符串转枚举 ---- */
|
||||
@@ -422,6 +423,22 @@ void memory_load(xmlNodePtr *root, AppConfig *out_cfg){
|
||||
}
|
||||
}
|
||||
|
||||
void redis_compat_load(xmlNodePtr *root, AppConfig *out_cfg) {
|
||||
xmlNodePtr redis_compat = find_child(*root, "redis_compat");
|
||||
if (!redis_compat) return;
|
||||
|
||||
xmlNodePtr auth_password_node = find_child(redis_compat, "auth_password");
|
||||
if (auth_password_node) {
|
||||
xmlChar *txt = xmlNodeGetContent(auth_password_node);
|
||||
if (txt) {
|
||||
strncpy(out_cfg->redis_auth_password, (char *)txt,
|
||||
sizeof(out_cfg->redis_auth_password) - 1);
|
||||
out_cfg->redis_auth_password[sizeof(out_cfg->redis_auth_password) - 1] = '\0';
|
||||
xmlFree(txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int config_load(const char *filename, AppConfig *out_cfg)
|
||||
{
|
||||
if (!filename || !out_cfg) return -1;
|
||||
@@ -470,6 +487,8 @@ int config_load(const char *filename, AppConfig *out_cfg)
|
||||
|
||||
memory_load(&root, out_cfg);
|
||||
|
||||
redis_compat_load(&root, out_cfg);
|
||||
|
||||
rc = 0;
|
||||
cleanup:
|
||||
if (doc) xmlFreeDoc(doc);
|
||||
|
||||
Reference in New Issue
Block a user