简单ttl懒删除支持

This commit is contained in:
1iaan
2026-04-04 22:31:00 +08:00
parent 6ede44bd80
commit 78519fbfe5
11 changed files with 375 additions and 98 deletions

View File

@@ -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);