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