jamesge commented on a change in pull request #972: Redis server protocol
URL: https://github.com/apache/incubator-brpc/pull/972#discussion_r358585429
##########
File path: src/brpc/policy/redis_protocol.cpp
##########
@@ -52,62 +54,202 @@ struct InputResponse : public InputMessageBase {
}
};
-// "Message" = "Response" as we only implement the client for redis.
+// This class is as parsing_context in socket.
+class RedisConnContext : public Destroyable {
+public:
+ RedisConnContext()
+ : redis_service(NULL)
+ , batched_size(0) {}
+
+ ~RedisConnContext();
+ // @Destroyable
+ void Destroy() override;
+
+ SocketId socket_id;
+ RedisService* redis_service;
+ // If user starts a transaction, handler_continue indicates the
+ // handler pointer that runs the transaction command.
+ std::unique_ptr<RedisCommandHandler> handler_continue;
+ // >0 if command handler is run in batched mode.
+ int batched_size;
+
+ RedisCommandParser parser;
+};
+
+static std::string ToLowercase(const std::string& command) {
+ std::string res;
+ res.resize(command.size());
+ std::transform(command.begin(), command.end(), res.begin(),
+ [](unsigned char c){ return std::tolower(c); });
+ return res;
+}
Review comment:
搜下现有代码,这种类型代码除非能获得性能收益,不要重写。另外那个tolower本身就能传给transform,没必要套lambda。
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]