Skip to content

Commit

Permalink
ensure rpoplpush can update cache (#2976)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheniujh authored Dec 16, 2024
1 parent 8ce0cb3 commit 9966db7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/pika_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/pika_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void InitCmdTable(CmdTable* cmd_table) {
std::make_unique<RPopCmd>(kCmdNameRPop, -2, kCmdFlagsWrite | kCmdFlagsList | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache | kCmdFlagsFast);
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameRPop, std::move(rpopptr)));
std::unique_ptr<Cmd> rpoplpushptr = std::make_unique<RPopLPushCmd>(
kCmdNameRPopLPush, 3, kCmdFlagsWrite | kCmdFlagsList | kCmdFlagsSlow);
kCmdNameRPopLPush, 3, kCmdFlagsWrite | kCmdFlagsList | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache | kCmdFlagsSlow);
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameRPopLPush, std::move(rpoplpushptr)));
std::unique_ptr<Cmd> rpushptr =
std::make_unique<RPushCmd>(kCmdNameRPush, -3, kCmdFlagsWrite | kCmdFlagsList | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache | kCmdFlagsFast);
Expand Down
11 changes: 11 additions & 0 deletions src/pika_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,17 @@ void RPopLPushCmd::DoBinlog() {
rpop_cmd_->DoBinlog();
lpush_cmd_->DoBinlog();
}
void RPopLPushCmd::DoUpdateCache() {
if (s_.ok()) {
std::vector<std::string> 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())) {
Expand Down

0 comments on commit 9966db7

Please sign in to comment.