Skip to content

Commit

Permalink
fix: incr/decr commands will lose TTL on slaves (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
whoiami committed Sep 29, 2019
1 parent 0d8bf02 commit 1befcbe
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 145 deletions.
25 changes: 0 additions & 25 deletions include/pika_kv.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ class IncrCmd : public Cmd {
private:
std::string key_, new_value_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
virtual std::string ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) override;
};

class IncrbyCmd : public Cmd {
Expand All @@ -70,11 +65,6 @@ class IncrbyCmd : public Cmd {
std::string key_, new_value_;
int64_t by_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
virtual std::string ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) override;
};

class IncrbyfloatCmd : public Cmd {
Expand All @@ -85,11 +75,6 @@ class IncrbyfloatCmd : public Cmd {
std::string key_, new_value_;
double by_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
virtual std::string ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) override;
};

class DecrCmd : public Cmd {
Expand All @@ -99,11 +84,6 @@ class DecrCmd : public Cmd {
private:
std::string key_, new_value_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
virtual std::string ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) override;
};

class DecrbyCmd : public Cmd {
Expand All @@ -114,11 +94,6 @@ class DecrbyCmd : public Cmd {
std::string key_, new_value_;
int64_t by_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
virtual std::string ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) override;
};

class GetsetCmd : public Cmd {
Expand Down
120 changes: 0 additions & 120 deletions src/pika_kv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,30 +147,6 @@ void IncrCmd::Do() {
return;
}

std::string IncrCmd::ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) {
std::string res;
res.reserve(RAW_ARGS_LEN);
RedisAppendLen(res, 3 + 4, "*");

// to set cmd
std::string set_cmd("set");
RedisAppendLen(res, set_cmd.size(), "$");
RedisAppendContent(res, set_cmd);
// key
RedisAppendLen(res, key_.size(), "$");
RedisAppendContent(res, key_);
// value
RedisAppendLen(res, new_value_.size(), "$");
RedisAppendContent(res, new_value_);

AppendAffiliatedInfo(res, server_id, binlog_info, need_send_to_hub);
return res;
}

void IncrbyCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info) {
if (!ptr_info->CheckArg(argv.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameIncrby);
Expand Down Expand Up @@ -199,30 +175,6 @@ void IncrbyCmd::Do() {
return;
}

std::string IncrbyCmd::ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) {
std::string res;
res.reserve(RAW_ARGS_LEN);
RedisAppendLen(res, 3 + 4, "*");

// to set cmd
std::string set_cmd("set");
RedisAppendLen(res, set_cmd.size(), "$");
RedisAppendContent(res, set_cmd);
// key
RedisAppendLen(res, key_.size(), "$");
RedisAppendContent(res, key_);
// value
RedisAppendLen(res, new_value_.size(), "$");
RedisAppendContent(res, new_value_);

AppendAffiliatedInfo(res, server_id, binlog_info, need_send_to_hub);
return res;
}

void IncrbyfloatCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info) {
if (!ptr_info->CheckArg(argv.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameIncrbyfloat);
Expand Down Expand Up @@ -252,30 +204,6 @@ void IncrbyfloatCmd::Do() {
return;
}

std::string IncrbyfloatCmd::ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) {
std::string res;
res.reserve(RAW_ARGS_LEN);
RedisAppendLen(res, 3 + 4, "*");

// to set cmd
std::string set_cmd("set");
RedisAppendLen(res, set_cmd.size(), "$");
RedisAppendContent(res, set_cmd);
// key
RedisAppendLen(res, key_.size(), "$");
RedisAppendContent(res, key_);
// value
RedisAppendLen(res, new_value_.size(), "$");
RedisAppendContent(res, new_value_);

AppendAffiliatedInfo(res, server_id, binlog_info, need_send_to_hub);
return res;
}

void DecrCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info) {
if (!ptr_info->CheckArg(argv.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameDecr);
Expand All @@ -299,30 +227,6 @@ void DecrCmd::Do() {
return;
}

std::string DecrCmd::ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) {
std::string res;
res.reserve(RAW_ARGS_LEN);
RedisAppendLen(res, 3 + 4, "*");

// to set cmd
std::string set_cmd("set");
RedisAppendLen(res, set_cmd.size(), "$");
RedisAppendContent(res, set_cmd);
// key
RedisAppendLen(res, key_.size(), "$");
RedisAppendContent(res, key_);
// value
RedisAppendLen(res, new_value_.size(), "$");
RedisAppendContent(res, new_value_);

AppendAffiliatedInfo(res, server_id, binlog_info, need_send_to_hub);
return res;
}

void DecrbyCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info) {
if (!ptr_info->CheckArg(argv.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameDecrby);
Expand Down Expand Up @@ -350,30 +254,6 @@ void DecrbyCmd::Do() {
return;
}

std::string DecrbyCmd::ToBinlog(
const PikaCmdArgsType& argv,
const std::string& server_id,
const std::string& binlog_info,
bool need_send_to_hub) {
std::string res;
res.reserve(RAW_ARGS_LEN);
RedisAppendLen(res, 3 + 4, "*");

// to set cmd
std::string set_cmd("set");
RedisAppendLen(res, set_cmd.size(), "$");
RedisAppendContent(res, set_cmd);
// key
RedisAppendLen(res, key_.size(), "$");
RedisAppendContent(res, key_);
// value
RedisAppendLen(res, new_value_.size(), "$");
RedisAppendContent(res, new_value_);

AppendAffiliatedInfo(res, server_id, binlog_info, need_send_to_hub);
return res;
}

void GetsetCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info) {
if (!ptr_info->CheckArg(argv.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameGetset);
Expand Down

0 comments on commit 1befcbe

Please sign in to comment.