* 发送REDIS命令到服务端 * @param[in] str 命令 * @return 服务端RESP协议返回值 * @see * @note */
| 134 | * @note |
| 135 | */ |
| 136 | QByteArray RedisClient::command(const QString & str) { |
| 137 | if(str.trimmed().isEmpty()) { |
| 138 | return "-str is empty\r\n"; |
| 139 | } |
| 140 | |
| 141 | _msg.clear(); |
| 142 | _sErrorInfo.clear(); |
| 143 | _sendData.clear(); |
| 144 | _bTimeout = false; |
| 145 | packRespCmd(str,_sendData); |
| 146 | if(_sendData.isEmpty()) { |
| 147 | return "-pack resp cmd is empty\r\n"; |
| 148 | } |
| 149 | |
| 150 | _redisTransMgr->write(_sendData); |
| 151 | |
| 152 | if(!_qTimer.isActive()) |
| 153 | _qTimer.start(); |
| 154 | _qEventloop.exec(); |
| 155 | if(_qTimer.isActive()) |
| 156 | _qTimer.stop(); |
| 157 | |
| 158 | if (_bTimeout) { |
| 159 | _sErrorInfo = "-run " + str + " timeout\r\n"; |
| 160 | return QByteArray(_sErrorInfo.toUtf8()); |
| 161 | } |
| 162 | |
| 163 | return _msg; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * 发送REDIS命令到服务端 |
no test coverage detected