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

Method Run

example/redis_c++/redis_server.cpp:140–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138 : _rsimpl(rsimpl) {}
139
140 brpc::RedisCommandHandlerResult Run(brpc::RedisConnContext* ctx,
141 const std::vector<butil::StringPiece>& args,
142 brpc::RedisReply* output,
143 bool /*flush_batched*/) override {
144 AuthSession* session = static_cast<AuthSession*>(ctx->get_session());
145 if (session == nullptr) {
146 output->FormatError("No auth session");
147 return brpc::REDIS_CMD_HANDLED;
148 }
149 if (session->_user_name.empty()) {
150 output->FormatError("No user name");
151 return brpc::REDIS_CMD_HANDLED;
152 }
153 if (args.size() != 3ul) {
154 output->FormatError("Expect 2 args for 'set', actually %lu", args.size()-1);
155 return brpc::REDIS_CMD_HANDLED;
156 }
157 const std::string key(args[1].data(), args[1].size());
158 const std::string value(args[2].data(), args[2].size());
159 _rsimpl->Set(session->_user_name, key, value);
160 output->SetStatus("OK");
161 return brpc::REDIS_CMD_HANDLED;
162 }
163
164private:
165 RedisServiceImpl* _rsimpl;

Callers

nothing calls this directly

Calls 7

get_sessionMethod · 0.80
FormatErrorMethod · 0.80
SetStatusMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected