Skip to content

Commit

Permalink
fix bitpos strlen msetnx
Browse files Browse the repository at this point in the history
  • Loading branch information
brother-jin committed Nov 15, 2023
1 parent 7f671fa commit 01f0315
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion conf/pika.conf
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ cache-num : 16
# cache-model 0:cache_none 1:cache_read
cache-model : 1
# cache-type: string, set, zset, list, hash, bit
cache-type: string, set, zset, list, hash, bit
cache-type: string, set, zset, list, hash
# cache-start-direction 0:cache first ${cache-items-per-key} items; -1:cache last ${cache-items-per-key} items
cache-start-direction : 0
cache-items-per-key : 512
Expand Down
1 change: 0 additions & 1 deletion include/pika_kv.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ class MsetnxCmd : public Cmd {
void DoInitial() override;
// used for write binlog
std::shared_ptr<SetCmd> set_cmd_;
rocksdb::Status s_;
};

class GetrangeCmd : public Cmd {
Expand Down
4 changes: 2 additions & 2 deletions src/pika_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void InitCmdTable(CmdTable* cmd_table) {
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameSetrange, std::move(setrangeptr)));
////StrlenCmd
std::unique_ptr<Cmd> strlenptr =
std::make_unique<StrlenCmd>(kCmdNameStrlen, 2, kCmdFlagsRead | kCmdFlagsSingleSlot | kCmdFlagsKv | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache);
std::make_unique<StrlenCmd>(kCmdNameStrlen, 2, kCmdFlagsRead | kCmdFlagsSingleSlot | kCmdFlagsKv | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache | kCmdFlagsReadCache);
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameStrlen, std::move(strlenptr)));
////ExistsCmd
std::unique_ptr<Cmd> existsptr =
Expand Down Expand Up @@ -618,7 +618,7 @@ void InitCmdTable(CmdTable* cmd_table) {
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameBitCount, std::move(bitcountptr)));
////bitposCmd
std::unique_ptr<Cmd> bitposptr =
std::make_unique<BitPosCmd>(kCmdNameBitPos, -3, kCmdFlagsRead | kCmdFlagsSingleSlot | kCmdFlagsBit | kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache);
std::make_unique<BitPosCmd>(kCmdNameBitPos, -3, kCmdFlagsRead | kCmdFlagsSingleSlot | kCmdFlagsBit| kCmdFlagsDoThroughDB | kCmdFlagsUpdateCache | kCmdFlagsReadCache);
cmd_table->insert(std::pair<std::string, std::unique_ptr<Cmd>>(kCmdNameBitPos, std::move(bitposptr)));
////bitopCmd
std::unique_ptr<Cmd> bitopptr =
Expand Down
9 changes: 6 additions & 3 deletions src/pika_kv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -927,15 +927,15 @@ void MsetnxCmd::DoInitial() {

void MsetnxCmd::Do(std::shared_ptr<Slot> slot) {
success_ = 0;
s_ = slot->db()->MSetnx(kvs_, &success_);
if (s_.ok()) {
rocksdb::Status s = slot->db()->MSetnx(kvs_, &success_);
if (s.ok()) {
res_.AppendInteger(success_);
std::vector<storage::KeyValue>::const_iterator it;
for (it = kvs_.begin(); it != kvs_.end(); it++) {
AddSlotKey("k", it->key, slot);
}
} else {
res_.SetRes(CmdRes::kErrOther, s_.ToString());
res_.SetRes(CmdRes::kErrOther, s.ToString());
}
}

Expand Down Expand Up @@ -1059,6 +1059,8 @@ void StrlenCmd::DoInitial() {
res_.SetRes(CmdRes::kWrongNum, kCmdNameStrlen);
return;
}
LOG(INFO) << "key:" << key_ ;
LOG(INFO) << "argv_[1]" << argv_[1];
key_ = argv_[1];
}

Expand All @@ -1067,6 +1069,7 @@ void StrlenCmd::Do(std::shared_ptr<Slot> slot) {
s_ = slot->db()->Strlen(key_, &len);
if (s_.ok() || s_.IsNotFound()) {
res_.AppendInteger(len);

} else {
res_.SetRes(CmdRes::kErrOther, s_.ToString());
}
Expand Down

0 comments on commit 01f0315

Please sign in to comment.