diff --git a/src/client.cc b/src/client.cc index 7d26e6d72..a07154951 100644 --- a/src/client.cc +++ b/src/client.cc @@ -76,7 +76,6 @@ void CmdRes::SetRes(CmdRes::CmdRet _ret, const std::string& content) { case kInvalidFloat: SetLineString("-ERR value is not a valid float"); break; - break; case kOverFlow: SetLineString("-ERR increment or decrement would overflow"); break; @@ -330,7 +329,7 @@ int PClient::handlePacket(const char* start, int bytes) { // const PCommandInfo* info = PCommandTable::GetCommandInfo(cmdName_); // if (!info) { // 如果这个命令不存在,那么就走新的命令处理流程 - handlePacketNew(); + executeCommand(); // return static_cast(ptr - start); // } @@ -376,7 +375,7 @@ int PClient::handlePacket(const char* start, int bytes) { // 为了兼容老的命令处理流程,新的命令处理流程在这里 // 后面可以把client这个类重构,完整的支持新的命令处理流程 -void PClient::handlePacketNew() { +void PClient::executeCommand() { auto [cmdPtr, ret] = g_pikiwidb->GetCmdTableManager().GetCommand(CmdName(), this); if (!cmdPtr) { @@ -520,7 +519,7 @@ bool PClient::isPeerMaster() const { return repl_addr.GetIP() == PeerIP() && repl_addr.GetPort() == PeerPort(); } -int PClient::UniqueId() const { +int PClient::uniqueID() const { if (auto c = getTcpConnection(); c) { return c->GetUniqueId(); } @@ -535,12 +534,12 @@ bool PClient::Watch(int dbno, const std::string& key) { bool PClient::NotifyDirty(int dbno, const std::string& key) { if (IsFlagOn(ClientFlagDirty)) { - INFO("client is already dirty {}", UniqueId()); + INFO("client is already dirty {}", uniqueID()); return true; } if (watch_keys_[dbno].contains(key)) { - INFO("{} client become dirty because key {} in db {}", UniqueId(), key, dbno); + INFO("{} client become dirty because key {} in db {}", uniqueID(), key, dbno); SetFlag(ClientFlagDirty); return true; } else { diff --git a/src/client.h b/src/client.h index 9f46c7b2b..708f4bb5a 100644 --- a/src/client.h +++ b/src/client.h @@ -60,7 +60,7 @@ class CmdRes { ret_ = kNone; } - inline std::string Message() const { return message_; }; + inline const std::string& Message() const { return message_; }; // Inline functions for Create Redis protocol inline void AppendStringLen(int64_t ori) { RedisAppendLen(message_, ori, "$"); } @@ -184,11 +184,11 @@ class PClient : public std::enable_shared_from_this, public CmdRes { private: std::shared_ptr getTcpConnection() const { return tcp_connection_.lock(); } int handlePacket(const char*, int); - void handlePacketNew(); + void executeCommand(); int processInlineCmd(const char*, size_t, std::vector&); void reset(); bool isPeerMaster() const; - int UniqueId() const; + int uniqueID() const; // TcpConnection's life is undetermined, so use weak ptr for safety. std::weak_ptr tcp_connection_;