MCPcopy Create free account
hub / github.com/apache/brpc / Run

Method Run

example/redis_c++/redis_server.cpp:103–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 : _rsimpl(rsimpl) {}
102
103 brpc::RedisCommandHandlerResult Run(brpc::RedisConnContext* ctx,
104 const std::vector<butil::StringPiece>& args,
105 brpc::RedisReply* output,
106 bool /*flush_batched*/) override {
107
108 AuthSession* session = static_cast<AuthSession*>(ctx->get_session());
109 if (session == nullptr) {
110 output->FormatError("No auth session");
111 return brpc::REDIS_CMD_HANDLED;
112 }
113 if (session->_user_name.empty()) {
114 output->FormatError("No user name");
115 return brpc::REDIS_CMD_HANDLED;
116 }
117 if (args.size() != 2ul) {
118 output->FormatError("Expect 1 arg for 'get', actually %lu", args.size()-1);
119 return brpc::REDIS_CMD_HANDLED;
120 }
121 const std::string key(args[1].data(), args[1].size());
122 std::string value;
123 if (_rsimpl->Get(session->_user_name, key, &value)) {
124 output->SetString(value);
125 } else {
126 output->SetNullString();
127 }
128 return brpc::REDIS_CMD_HANDLED;
129 }
130
131private:
132 RedisServiceImpl* _rsimpl;

Callers

nothing calls this directly

Calls 8

get_sessionMethod · 0.80
FormatErrorMethod · 0.80
SetNullStringMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
GetMethod · 0.45
SetStringMethod · 0.45

Tested by

no test coverage detected