From 6d3194aea7284b8be746b2d74a09b9a73034f677 Mon Sep 17 00:00:00 2001 From: chejinge Date: Tue, 2 Sep 2025 17:24:02 +0800 Subject: [PATCH 1/3] add RTC command --- src/pika_client_conn.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/pika_client_conn.cc b/src/pika_client_conn.cc index 5dc33caace..9bcaaa4bdf 100644 --- a/src/pika_client_conn.cc +++ b/src/pika_client_conn.cc @@ -273,13 +273,26 @@ void PikaClientConn::ProcessMonitor(const PikaCmdArgsType& argv) { } bool PikaClientConn::IsInterceptedByRTC(std::string& opt) { - // currently we only Intercept: Get, HGet - if (opt == kCmdNameGet && g_pika_conf->GetCacheString()) { + + static const std::unordered_set intercepted_string_cmds = { + kCmdNameGet, kCmdNameStrlen, kCmdNameTtl + }; + + static const std::unordered_set intercepted_hash_cmds = { + kCmdNameHGet, kCmdNameHMget, kCmdNameHExists, kCmdNameHVals, kCmdNameHStrlen + }; + + static const std::unordered_set intercepted_list_cmds = { + kCmdNameLLen + }; + + if (intercepted_string_cmds.count(opt) && g_pika_conf->GetCacheString()) { return true; } - if (opt == kCmdNameHGet && g_pika_conf->GetCacheHash()) { + if (intercepted_hash_cmds.count(opt) && g_pika_conf->GetCacheHash()) { return true; } + return false; } From 61a08130c422bf5d562ca83d36e63c9d5f8e1974 Mon Sep 17 00:00:00 2001 From: chejinge Date: Tue, 2 Sep 2025 17:24:02 +0800 Subject: [PATCH 2/3] add RTC command --- src/pika_client_conn.cc | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/pika_client_conn.cc b/src/pika_client_conn.cc index 5dc33caace..4eb6e11fbd 100644 --- a/src/pika_client_conn.cc +++ b/src/pika_client_conn.cc @@ -273,13 +273,29 @@ void PikaClientConn::ProcessMonitor(const PikaCmdArgsType& argv) { } bool PikaClientConn::IsInterceptedByRTC(std::string& opt) { - // currently we only Intercept: Get, HGet - if (opt == kCmdNameGet && g_pika_conf->GetCacheString()) { + + static const std::unordered_set intercepted_string_cmds = { + kCmdNameGet, kCmdNameStrlen, kCmdNameTtl + }; + + static const std::unordered_set intercepted_hash_cmds = { + kCmdNameHGet, kCmdNameHMget, kCmdNameHExists, kCmdNameHVals, kCmdNameHStrlen + }; + + static const std::unordered_set intercepted_list_cmds = { + kCmdNameLLen + }; + + if (intercepted_string_cmds.count(opt) && g_pika_conf->GetCacheString()) { return true; } - if (opt == kCmdNameHGet && g_pika_conf->GetCacheHash()) { + if (intercepted_hash_cmds.count(opt) && g_pika_conf->GetCacheHash()) { return true; } + if (intercepted_list_cmds.count(opt) && g_pika_conf->GetCacheList()) { + return true; + } + return false; } From 4e227a954555174fb7b91eb2026ef4821102b745 Mon Sep 17 00:00:00 2001 From: chejinge <945997690@qq.com> Date: Fri, 5 Sep 2025 15:54:07 +0800 Subject: [PATCH 3/3] Remove unused intercepted_list_cmds Removed unused intercepted_list_cmds set from pika_client_conn.cc. --- src/pika_client_conn.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/pika_client_conn.cc b/src/pika_client_conn.cc index 4eb6e11fbd..1919520c8c 100644 --- a/src/pika_client_conn.cc +++ b/src/pika_client_conn.cc @@ -282,19 +282,12 @@ bool PikaClientConn::IsInterceptedByRTC(std::string& opt) { kCmdNameHGet, kCmdNameHMget, kCmdNameHExists, kCmdNameHVals, kCmdNameHStrlen }; - static const std::unordered_set intercepted_list_cmds = { - kCmdNameLLen - }; - if (intercepted_string_cmds.count(opt) && g_pika_conf->GetCacheString()) { return true; } if (intercepted_hash_cmds.count(opt) && g_pika_conf->GetCacheHash()) { return true; } - if (intercepted_list_cmds.count(opt) && g_pika_conf->GetCacheList()) { - return true; - } return false; }