From 9966db71dbb14f2fd1fb41a07f2485fd5a71822a Mon Sep 17 00:00:00 2001 From: cheniujh <1271435567@qq.com> Date: Mon, 16 Dec 2024 15:18:26 +0800 Subject: [PATCH] ensure rpoplpush can update cache (#2976) --- include/pika_list.h | 2 ++ src/pika_command.cc | 2 +- src/pika_list.cc | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/pika_list.h b/include/pika_list.h index 1591e76c32..49031b074e 100644 --- a/include/pika_list.h +++ b/include/pika_list.h @@ -364,6 +364,8 @@ class RPopLPushCmd : public BlockingBaseCmd { void ReadCache() override; void Split(const HintKeys& hint_keys) override{}; void Merge() override{}; + void DoThroughDB() override; + void DoUpdateCache() override; Cmd* Clone() override { return new RPopLPushCmd(*this); } void DoBinlog() override; diff --git a/src/pika_command.cc b/src/pika_command.cc index 0046b17109..7e2c9ba83c 100644 --- a/src/pika_command.cc +++ b/src/pika_command.cc @@ -501,7 +501,7 @@ void InitCmdTable(CmdTable* cmd_table) { std::make_unique(kCmdNameRPop, -2, kCmdFlagsWrite | kCmdFlagsList | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache | kCmdFlagsFast); cmd_table->insert(std::pair>(kCmdNameRPop, std::move(rpopptr))); std::unique_ptr rpoplpushptr = std::make_unique( - kCmdNameRPopLPush, 3, kCmdFlagsWrite | kCmdFlagsList | kCmdFlagsSlow); + kCmdNameRPopLPush, 3, kCmdFlagsWrite | kCmdFlagsList | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache | kCmdFlagsSlow); cmd_table->insert(std::pair>(kCmdNameRPopLPush, std::move(rpoplpushptr))); std::unique_ptr rpushptr = std::make_unique(kCmdNameRPush, -3, kCmdFlagsWrite | kCmdFlagsList | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache | kCmdFlagsFast); diff --git a/src/pika_list.cc b/src/pika_list.cc index 9cec350baa..fa57dde372 100644 --- a/src/pika_list.cc +++ b/src/pika_list.cc @@ -847,6 +847,17 @@ void RPopLPushCmd::DoBinlog() { rpop_cmd_->DoBinlog(); lpush_cmd_->DoBinlog(); } +void RPopLPushCmd::DoUpdateCache() { + if (s_.ok()) { + std::vector value; + value.resize(1); + db_->cache()->RPop(source_, &value[0]); + db_->cache()->LPushx(receiver_, value); + } +} +void RPopLPushCmd::DoThroughDB() { + Do(); +} void RPushCmd::DoInitial() { if (!CheckArg(argv_.size())) {