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

Method Run

test/brpc_redis_unittest.cpp:1028–1051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026 : _rs(rs) {}
1027
1028 brpc::RedisCommandHandlerResult Run(brpc::RedisConnContext* ctx,
1029 const std::vector<butil::StringPiece>& args,
1030 brpc::RedisReply* output,
1031 bool flush_batched) {
1032 if (!ctx->session) {
1033 output->SetError("ERR no auth");
1034 return brpc::REDIS_CMD_HANDLED;
1035 }
1036 AuthSession* session = static_cast<AuthSession*>(ctx->session);
1037 if (session->_password != _rs->_password) {
1038 output->SetError("ERR no auth");
1039 return brpc::REDIS_CMD_HANDLED;
1040 }
1041 if (args.size() < 2) {
1042 output->SetError("ERR wrong number of arguments for 'incr' command");
1043 return brpc::REDIS_CMD_HANDLED;
1044 }
1045 int64_t value;
1046 s_mutex.lock();
1047 value = ++int_map[args[1].as_string()];
1048 s_mutex.unlock();
1049 output->SetInteger(value);
1050 return brpc::REDIS_CMD_HANDLED;
1051 }
1052
1053private:
1054 RedisServiceImpl* _rs;

Callers

nothing calls this directly

Calls 6

SetIntegerMethod · 0.80
SetErrorMethod · 0.45
sizeMethod · 0.45
lockMethod · 0.45
as_stringMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected