| 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 | |
| 131 | private: |
| 132 | RedisServiceImpl* _rsimpl; |
nothing calls this directly
no test coverage detected