diff --git a/include/pika_conf.h b/include/pika_conf.h index 5aa0c790c..5f9e5db08 100644 --- a/include/pika_conf.h +++ b/include/pika_conf.h @@ -772,6 +772,11 @@ class PikaConf : public pstd::BaseConf { TryPushDiffCommands("write-buffer-size", std::to_string(value)); write_buffer_size_ = value; } + void SetLogRetentionTime(const int& value) { + std::lock_guard l(rwlock_); + TryPushDiffCommands("log-retention-time", std::to_string(value)); + log_retention_time_ = value; + } void SetMinWriteBufferNumberToMerge(const int& value) { std::lock_guard l(rwlock_); TryPushDiffCommands("min-write-buffer-number-to-merge", std::to_string(value)); diff --git a/src/pika_admin.cc b/src/pika_admin.cc index 42861349a..d07ce3e32 100644 --- a/src/pika_admin.cc +++ b/src/pika_admin.cc @@ -1590,6 +1590,12 @@ void ConfigCmd::ConfigGet(std::string& ret) { EncodeNumber(&config_body, g_pika_conf->port()); } + if (pstd::stringmatch(pattern.data(), "log-retention-time", 1) != 0) { + elements += 2; + EncodeString(&config_body, "log-retention-time"); + EncodeNumber(&config_body, g_pika_conf->log_retention_time()); + } + if (pstd::stringmatch(pattern.data(), "thread-num", 1) != 0) { elements += 2; EncodeString(&config_body, "thread-num"); @@ -2351,6 +2357,13 @@ void ConfigCmd::ConfigSet(std::shared_ptr db) { } g_pika_conf->SetTimeout(static_cast(ival)); res_.AppendStringRaw("+OK\r\n"); + } else if (set_item == "log-retention-time") { + if (pstd::string2int(value.data(), value.size(), &ival) == 0 || ival <= 0) { + res_.AppendStringRaw("-ERR Invalid argument " + value + " for CONFIG SET 'log-retention-time'\r\n"); + return; + } + g_pika_conf->SetLogRetentionTime(static_cast(ival)); + res_.AppendStringRaw("+OK\r\n"); } else if (set_item == "requirepass") { g_pika_conf->SetRequirePass(value); g_pika_server->Acl()->UpdateDefaultUserPassword(value);