Skip to content

Commit

Permalink
Removed DoThroughDB()
Browse files Browse the repository at this point in the history
  • Loading branch information
olapiv committed Nov 13, 2024
1 parent 2626c28 commit 0aa9c35
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 159 deletions.
1 change: 0 additions & 1 deletion pink/rondis/cmd_builder/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ class Cmd : public std::enable_shared_from_this<Cmd> {
virtual std::vector<std::string> current_key() const;
virtual void Execute();
virtual void Do() {};
virtual void DoThroughDB() {}
virtual void ReadCache() {}
virtual Cmd* Clone() = 0;
// used for execute multikey command into different slots
Expand Down
131 changes: 0 additions & 131 deletions pink/rondis/cmd_builder/kv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ void SetCmd::Do() {
}
}

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

std::string SetCmd::ToRedisProtocol() {
if (condition_ == SetCmd::kEXORPX) {
std::string content;
Expand Down Expand Up @@ -165,11 +161,6 @@ void GetCmd::ReadCache() {
}
}

void GetCmd::DoThroughDB() {
res_.clear();
Do();
}

#if DISABLE_CMDS_SECTION

void DelCmd::DoInitial() {
Expand All @@ -196,10 +187,6 @@ void DelCmd::Do() {
}
}

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

void DelCmd::Split(const HintKeys& hint_keys) {
std::map<storage::DataType, storage::Status> type_status;
int64_t count = db_->storage()->Del(hint_keys.keys);
Expand Down Expand Up @@ -236,10 +223,6 @@ void IncrCmd::Do() {
}
}

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

std::string IncrCmd::ToRedisProtocol() {
std::string content;
content.reserve(RAW_ARGS_LEN);
Expand Down Expand Up @@ -294,10 +277,6 @@ void IncrbyCmd::Do() {
}
}

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

std::string IncrbyCmd::ToRedisProtocol() {
std::string content;
content.reserve(RAW_ARGS_LEN);
Expand Down Expand Up @@ -354,10 +333,6 @@ void IncrbyfloatCmd::Do() {
}
}

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

std::string IncrbyfloatCmd::ToRedisProtocol() {
std::string content;
content.reserve(RAW_ARGS_LEN);
Expand Down Expand Up @@ -407,10 +382,6 @@ void DecrCmd::Do() {
}
}

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

void DecrbyCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameDecrby);
Expand Down Expand Up @@ -439,10 +410,6 @@ void DecrbyCmd::Do() {
}
}

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

void GetsetCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameGetset);
Expand Down Expand Up @@ -470,10 +437,6 @@ void GetsetCmd::Do() {
}
}

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

void AppendCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameAppend);
Expand All @@ -496,10 +459,6 @@ void AppendCmd::Do() {
}
}

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

std::string AppendCmd::ToRedisProtocol() {
std::string content;
content.reserve(RAW_ARGS_LEN);
Expand Down Expand Up @@ -599,11 +558,6 @@ void MgetCmd::Merge() {
}
}

void MgetCmd::DoThroughDB() {
res_.clear();
Do();
}

void MgetCmd::ReadCache() {
for (const auto key : keys_) {
std::string value;
Expand Down Expand Up @@ -763,10 +717,6 @@ void SetexCmd::Do() {
}
}

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

std::string SetexCmd::ToRedisProtocol() {
std::string content;
content.reserve(RAW_ARGS_LEN);
Expand Down Expand Up @@ -816,10 +766,6 @@ void PsetexCmd::Do() {
}
}

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

std::string PsetexCmd::ToRedisProtocol() {
std::string content;
content.reserve(RAW_ARGS_LEN);
Expand Down Expand Up @@ -896,10 +842,6 @@ void MsetCmd::Do() {
}
}

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

void MsetCmd::Split(const HintKeys& hint_keys) {
std::vector<storage::KeyValue> kvs;
const std::vector<std::string>& keys = hint_keys.keys;
Expand Down Expand Up @@ -998,21 +940,6 @@ void GetrangeCmd::ReadCache() {
}
}

void GetrangeCmd::DoThroughDB() {
res_.clear();
std::string substr;
s_ = db_->storage()->GetrangeWithValue(key_, start_, end_, &substr, &value_, &sec_);
if (s_.ok()) {
res_.AppendStringLen(substr.size());
res_.AppendContent(substr);
} else if (s_.IsNotFound()) {
res_.AppendStringLen(substr.size());
res_.AppendContent(substr);
} else {
res_.SetRes(CmdRes::kErrOther, s_.ToString());
}
}

void SetrangeCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameSetrange);
Expand All @@ -1039,10 +966,6 @@ void SetrangeCmd::Do() {
}
}

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

void StrlenCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameStrlen);
Expand Down Expand Up @@ -1073,16 +996,6 @@ void StrlenCmd::ReadCache() {
}
}

void StrlenCmd::DoThroughDB() {
res_.clear();
s_ = db_->storage()->GetWithTTL(key_, &value_, &ttl_millsec);
if (s_.ok() || s_.IsNotFound()) {
res_.AppendInteger(value_.size());
} else {
res_.SetRes(CmdRes::kErrOther, s_.ToString());
}
}

void ExistsCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameExists);
Expand Down Expand Up @@ -1125,11 +1038,6 @@ void ExistsCmd::ReadCache() {
}
}

void ExistsCmd::DoThroughDB() {
res_.clear();
Do();
}

void ExpireCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameExpire);
Expand Down Expand Up @@ -1175,10 +1083,6 @@ std::string ExpireCmd::ToRedisProtocol() {
return content;
}

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

void PexpireCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNamePexpire);
Expand Down Expand Up @@ -1224,10 +1128,6 @@ std::string PexpireCmd::ToRedisProtocol() {
return content;
}

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

void ExpireatCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameExpireat);
Expand All @@ -1251,10 +1151,6 @@ void ExpireatCmd::Do() {
}
}

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

void PexpireatCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNamePexpireat);
Expand All @@ -1278,10 +1174,6 @@ void PexpireatCmd::Do() {
}
}

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

void TtlCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameTtl);
Expand Down Expand Up @@ -1310,11 +1202,6 @@ void TtlCmd::ReadCache() {
}
}

void TtlCmd::DoThroughDB() {
res_.clear();
Do();
}

void PttlCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNamePttl);
Expand All @@ -1334,11 +1221,6 @@ void PttlCmd::Do() {

void PttlCmd::ReadCache() {
// redis cache don't support pttl cache, so read directly from db
DoThroughDB();
}

void PttlCmd::DoThroughDB() {
res_.clear();
Do();
}

Expand All @@ -1361,10 +1243,6 @@ void PersistCmd::Do() {
}
}

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

void TypeCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameType);
Expand Down Expand Up @@ -1398,11 +1276,6 @@ void TypeCmd::ReadCache() {
}
}

void TypeCmd::DoThroughDB() {
res_.clear();
Do();
}

void ScanCmd::DoInitial() {
if (!CheckArg(argv_.size())) {
res_.SetRes(CmdRes::kWrongNum, kCmdNameScan);
Expand Down Expand Up @@ -1573,10 +1446,6 @@ void PKSetexAtCmd::Do() {
}
}

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

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

0 comments on commit 0aa9c35

Please sign in to comment.