| 940 | , _batch_process(batch_process) {} |
| 941 | |
| 942 | brpc::RedisCommandHandlerResult Run(brpc::RedisConnContext* ctx, |
| 943 | const std::vector<butil::StringPiece>& args, |
| 944 | brpc::RedisReply* output, |
| 945 | bool flush_batched) { |
| 946 | if (!ctx->session) { |
| 947 | output->SetError("ERR no auth"); |
| 948 | return brpc::REDIS_CMD_HANDLED; |
| 949 | } |
| 950 | AuthSession* session = static_cast<AuthSession*>(ctx->session); |
| 951 | if (!session || (session->_password != _rs->_password)) { |
| 952 | output->SetError("ERR no auth"); |
| 953 | return brpc::REDIS_CMD_HANDLED; |
| 954 | } |
| 955 | if (args.size() < 3) { |
| 956 | output->SetError("ERR wrong number of arguments for 'set' command"); |
| 957 | return brpc::REDIS_CMD_HANDLED; |
| 958 | } |
| 959 | if (_batch_process) { |
| 960 | return _rs->OnBatched(args, output, flush_batched); |
| 961 | } else { |
| 962 | DoSet(args[1].as_string(), args[2].as_string(), output); |
| 963 | return brpc::REDIS_CMD_HANDLED; |
| 964 | } |
| 965 | } |
| 966 | |
| 967 | void DoSet(const std::string& key, const std::string& value, brpc::RedisReply* output) { |
| 968 | m[key] = value; |