Skip to content

Commit a0067de

Browse files
committed
Removed DoThroughDB()
1 parent cb69835 commit a0067de

File tree

3 files changed

+27
-159
lines changed

3 files changed

+27
-159
lines changed

pink/rondis/cmd_builder/command.h

-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ class Cmd : public std::enable_shared_from_this<Cmd> {
495495
virtual std::vector<std::string> current_key() const;
496496
virtual void Execute();
497497
virtual void Do() {};
498-
virtual void DoThroughDB() {}
499498
virtual void ReadCache() {}
500499
virtual Cmd* Clone() = 0;
501500
// used for execute multikey command into different slots

pink/rondis/cmd_builder/kv.cc

-131
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ void SetCmd::Do() {
9898
}
9999
}
100100

101-
void SetCmd::DoThroughDB() {
102-
Do();
103-
}
104-
105101
std::string SetCmd::ToRedisProtocol() {
106102
if (condition_ == SetCmd::kEXORPX) {
107103
std::string content;
@@ -165,11 +161,6 @@ void GetCmd::ReadCache() {
165161
}
166162
}
167163

168-
void GetCmd::DoThroughDB() {
169-
res_.clear();
170-
Do();
171-
}
172-
173164
#if DISABLE_CMDS_SECTION
174165

175166
void DelCmd::DoInitial() {
@@ -196,10 +187,6 @@ void DelCmd::Do() {
196187
}
197188
}
198189

199-
void DelCmd::DoThroughDB() {
200-
Do();
201-
}
202-
203190
void DelCmd::Split(const HintKeys& hint_keys) {
204191
std::map<storage::DataType, storage::Status> type_status;
205192
int64_t count = db_->storage()->Del(hint_keys.keys);
@@ -236,10 +223,6 @@ void IncrCmd::Do() {
236223
}
237224
}
238225

239-
void IncrCmd::DoThroughDB() {
240-
Do();
241-
}
242-
243226
std::string IncrCmd::ToRedisProtocol() {
244227
std::string content;
245228
content.reserve(RAW_ARGS_LEN);
@@ -294,10 +277,6 @@ void IncrbyCmd::Do() {
294277
}
295278
}
296279

297-
void IncrbyCmd::DoThroughDB() {
298-
Do();
299-
}
300-
301280
std::string IncrbyCmd::ToRedisProtocol() {
302281
std::string content;
303282
content.reserve(RAW_ARGS_LEN);
@@ -354,10 +333,6 @@ void IncrbyfloatCmd::Do() {
354333
}
355334
}
356335

357-
void IncrbyfloatCmd::DoThroughDB() {
358-
Do();
359-
}
360-
361336
std::string IncrbyfloatCmd::ToRedisProtocol() {
362337
std::string content;
363338
content.reserve(RAW_ARGS_LEN);
@@ -407,10 +382,6 @@ void DecrCmd::Do() {
407382
}
408383
}
409384

410-
void DecrCmd::DoThroughDB() {
411-
Do();
412-
}
413-
414385
void DecrbyCmd::DoInitial() {
415386
if (!CheckArg(argv_.size())) {
416387
res_.SetRes(CmdRes::kWrongNum, kCmdNameDecrby);
@@ -439,10 +410,6 @@ void DecrbyCmd::Do() {
439410
}
440411
}
441412

442-
void DecrbyCmd::DoThroughDB() {
443-
Do();
444-
}
445-
446413
void GetsetCmd::DoInitial() {
447414
if (!CheckArg(argv_.size())) {
448415
res_.SetRes(CmdRes::kWrongNum, kCmdNameGetset);
@@ -470,10 +437,6 @@ void GetsetCmd::Do() {
470437
}
471438
}
472439

473-
void GetsetCmd::DoThroughDB() {
474-
Do();
475-
}
476-
477440
void AppendCmd::DoInitial() {
478441
if (!CheckArg(argv_.size())) {
479442
res_.SetRes(CmdRes::kWrongNum, kCmdNameAppend);
@@ -496,10 +459,6 @@ void AppendCmd::Do() {
496459
}
497460
}
498461

499-
void AppendCmd::DoThroughDB() {
500-
Do();
501-
}
502-
503462
std::string AppendCmd::ToRedisProtocol() {
504463
std::string content;
505464
content.reserve(RAW_ARGS_LEN);
@@ -599,11 +558,6 @@ void MgetCmd::Merge() {
599558
}
600559
}
601560

602-
void MgetCmd::DoThroughDB() {
603-
res_.clear();
604-
Do();
605-
}
606-
607561
void MgetCmd::ReadCache() {
608562
for (const auto key : keys_) {
609563
std::string value;
@@ -763,10 +717,6 @@ void SetexCmd::Do() {
763717
}
764718
}
765719

766-
void SetexCmd::DoThroughDB() {
767-
Do();
768-
}
769-
770720
std::string SetexCmd::ToRedisProtocol() {
771721
std::string content;
772722
content.reserve(RAW_ARGS_LEN);
@@ -816,10 +766,6 @@ void PsetexCmd::Do() {
816766
}
817767
}
818768

819-
void PsetexCmd::DoThroughDB() {
820-
Do();
821-
}
822-
823769
std::string PsetexCmd::ToRedisProtocol() {
824770
std::string content;
825771
content.reserve(RAW_ARGS_LEN);
@@ -896,10 +842,6 @@ void MsetCmd::Do() {
896842
}
897843
}
898844

899-
void MsetCmd::DoThroughDB() {
900-
Do();
901-
}
902-
903845
void MsetCmd::Split(const HintKeys& hint_keys) {
904846
std::vector<storage::KeyValue> kvs;
905847
const std::vector<std::string>& keys = hint_keys.keys;
@@ -998,21 +940,6 @@ void GetrangeCmd::ReadCache() {
998940
}
999941
}
1000942

1001-
void GetrangeCmd::DoThroughDB() {
1002-
res_.clear();
1003-
std::string substr;
1004-
s_ = db_->storage()->GetrangeWithValue(key_, start_, end_, &substr, &value_, &sec_);
1005-
if (s_.ok()) {
1006-
res_.AppendStringLen(substr.size());
1007-
res_.AppendContent(substr);
1008-
} else if (s_.IsNotFound()) {
1009-
res_.AppendStringLen(substr.size());
1010-
res_.AppendContent(substr);
1011-
} else {
1012-
res_.SetRes(CmdRes::kErrOther, s_.ToString());
1013-
}
1014-
}
1015-
1016943
void SetrangeCmd::DoInitial() {
1017944
if (!CheckArg(argv_.size())) {
1018945
res_.SetRes(CmdRes::kWrongNum, kCmdNameSetrange);
@@ -1039,10 +966,6 @@ void SetrangeCmd::Do() {
1039966
}
1040967
}
1041968

1042-
void SetrangeCmd::DoThroughDB() {
1043-
Do();
1044-
}
1045-
1046969
void StrlenCmd::DoInitial() {
1047970
if (!CheckArg(argv_.size())) {
1048971
res_.SetRes(CmdRes::kWrongNum, kCmdNameStrlen);
@@ -1073,16 +996,6 @@ void StrlenCmd::ReadCache() {
1073996
}
1074997
}
1075998

1076-
void StrlenCmd::DoThroughDB() {
1077-
res_.clear();
1078-
s_ = db_->storage()->GetWithTTL(key_, &value_, &ttl_millsec);
1079-
if (s_.ok() || s_.IsNotFound()) {
1080-
res_.AppendInteger(value_.size());
1081-
} else {
1082-
res_.SetRes(CmdRes::kErrOther, s_.ToString());
1083-
}
1084-
}
1085-
1086999
void ExistsCmd::DoInitial() {
10871000
if (!CheckArg(argv_.size())) {
10881001
res_.SetRes(CmdRes::kWrongNum, kCmdNameExists);
@@ -1125,11 +1038,6 @@ void ExistsCmd::ReadCache() {
11251038
}
11261039
}
11271040

1128-
void ExistsCmd::DoThroughDB() {
1129-
res_.clear();
1130-
Do();
1131-
}
1132-
11331041
void ExpireCmd::DoInitial() {
11341042
if (!CheckArg(argv_.size())) {
11351043
res_.SetRes(CmdRes::kWrongNum, kCmdNameExpire);
@@ -1175,10 +1083,6 @@ std::string ExpireCmd::ToRedisProtocol() {
11751083
return content;
11761084
}
11771085

1178-
void ExpireCmd::DoThroughDB() {
1179-
Do();
1180-
}
1181-
11821086
void PexpireCmd::DoInitial() {
11831087
if (!CheckArg(argv_.size())) {
11841088
res_.SetRes(CmdRes::kWrongNum, kCmdNamePexpire);
@@ -1224,10 +1128,6 @@ std::string PexpireCmd::ToRedisProtocol() {
12241128
return content;
12251129
}
12261130

1227-
void PexpireCmd::DoThroughDB() {
1228-
Do();
1229-
}
1230-
12311131
void ExpireatCmd::DoInitial() {
12321132
if (!CheckArg(argv_.size())) {
12331133
res_.SetRes(CmdRes::kWrongNum, kCmdNameExpireat);
@@ -1251,10 +1151,6 @@ void ExpireatCmd::Do() {
12511151
}
12521152
}
12531153

1254-
void ExpireatCmd::DoThroughDB() {
1255-
Do();
1256-
}
1257-
12581154
void PexpireatCmd::DoInitial() {
12591155
if (!CheckArg(argv_.size())) {
12601156
res_.SetRes(CmdRes::kWrongNum, kCmdNamePexpireat);
@@ -1278,10 +1174,6 @@ void PexpireatCmd::Do() {
12781174
}
12791175
}
12801176

1281-
void PexpireatCmd::DoThroughDB() {
1282-
Do();
1283-
}
1284-
12851177
void TtlCmd::DoInitial() {
12861178
if (!CheckArg(argv_.size())) {
12871179
res_.SetRes(CmdRes::kWrongNum, kCmdNameTtl);
@@ -1310,11 +1202,6 @@ void TtlCmd::ReadCache() {
13101202
}
13111203
}
13121204

1313-
void TtlCmd::DoThroughDB() {
1314-
res_.clear();
1315-
Do();
1316-
}
1317-
13181205
void PttlCmd::DoInitial() {
13191206
if (!CheckArg(argv_.size())) {
13201207
res_.SetRes(CmdRes::kWrongNum, kCmdNamePttl);
@@ -1334,11 +1221,6 @@ void PttlCmd::Do() {
13341221

13351222
void PttlCmd::ReadCache() {
13361223
// redis cache don't support pttl cache, so read directly from db
1337-
DoThroughDB();
1338-
}
1339-
1340-
void PttlCmd::DoThroughDB() {
1341-
res_.clear();
13421224
Do();
13431225
}
13441226

@@ -1361,10 +1243,6 @@ void PersistCmd::Do() {
13611243
}
13621244
}
13631245

1364-
void PersistCmd::DoThroughDB() {
1365-
Do();
1366-
}
1367-
13681246
void TypeCmd::DoInitial() {
13691247
if (!CheckArg(argv_.size())) {
13701248
res_.SetRes(CmdRes::kWrongNum, kCmdNameType);
@@ -1398,11 +1276,6 @@ void TypeCmd::ReadCache() {
13981276
}
13991277
}
14001278

1401-
void TypeCmd::DoThroughDB() {
1402-
res_.clear();
1403-
Do();
1404-
}
1405-
14061279
void ScanCmd::DoInitial() {
14071280
if (!CheckArg(argv_.size())) {
14081281
res_.SetRes(CmdRes::kWrongNum, kCmdNameScan);
@@ -1573,10 +1446,6 @@ void PKSetexAtCmd::Do() {
15731446
}
15741447
}
15751448

1576-
void PKSetexAtCmd::DoThroughDB() {
1577-
Do();
1578-
}
1579-
15801449
void PKScanRangeCmd::DoInitial() {
15811450
if (!CheckArg(argv_.size())) {
15821451
res_.SetRes(CmdRes::kWrongNum, kCmdNamePKScanRange);

0 commit comments

Comments
 (0)