Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pksetexat should update cache #2736

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/pika_kv.h
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,8 @@ class PKSetexAtCmd : public Cmd {
return res;
}
void Do() override;
void DoThroughDB() override;
void DoUpdateCache() override;
void Split(const HintKeys& hint_keys) override {};
void Merge() override {};
Cmd* Clone() override { return new PKSetexAtCmd(*this); }
Expand Down
2 changes: 1 addition & 1 deletion src/pika_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void InitCmdTable(CmdTable* cmd_table) {
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameScanx, std::move(scanxptr)));
////PKSetexAtCmd
std::unique_ptr<Cmd> pksetexatptr = std::make_unique<PKSetexAtCmd>(
kCmdNamePKSetexAt, 4, kCmdFlagsWrite | kCmdFlagsKv | kCmdFlagsSlow);
kCmdNamePKSetexAt, 4, kCmdFlagsWrite | kCmdFlagsKv | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache | kCmdFlagsSlow);
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNamePKSetexAt, std::move(pksetexatptr)));
////PKScanRange
std::unique_ptr<Cmd> pkscanrangeptr = std::make_unique<PKScanRangeCmd>(
Expand Down
15 changes: 15 additions & 0 deletions src/pika_kv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,21 @@ void PKSetexAtCmd::Do() {
}
}

void PKSetexAtCmd::DoThroughDB() {
Do();
}

void PKSetexAtCmd::DoUpdateCache() {
chejinge marked this conversation as resolved.
Show resolved Hide resolved
if (s_.ok()) {
auto expire = time_stamp_ - static_cast<int64_t>(std::time(nullptr));
if (expire <= 0) [[unlikely]] {
db_->cache()->Del({key_});
return;
}
db_->cache()->Setxx(key_, value_, expire);
}
}

void PKScanRangeCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNamePKScanRange);
Expand Down
Loading