* 返回一个集合的全部成员,该集合是所有给定集合之间的并集 * 不存在的key被视为空集 * @param[in] keys 一个或多个集合 * @param[out] value 集合并集 * @return 成功true,失败false * @see * @note */
| 4287 | * @note |
| 4288 | */ |
| 4289 | bool RedisClient::sunion(const QString & keys, QList<QByteArray> & value) { |
| 4290 | _sErrorInfo.clear(); |
| 4291 | if(keys.trimmed().isEmpty()) { |
| 4292 | _sErrorInfo = "key is empty"; |
| 4293 | return false; |
| 4294 | } |
| 4295 | |
| 4296 | _vCmdList.clear(); |
| 4297 | _vCmdList.push_back("SUNION"); |
| 4298 | _vCmdList.push_back(keys); |
| 4299 | |
| 4300 | _cmdResult = command(_vCmdList); |
| 4301 | if(_cmdResult[0] == '-') { |
| 4302 | if(parseRespError(_cmdResult,_sValue)) |
| 4303 | _sErrorInfo = _sValue; |
| 4304 | else |
| 4305 | _sErrorInfo = "parser resp error info failed"; |
| 4306 | _bRet = false; |
| 4307 | } else if(_cmdResult[0] == '*') { |
| 4308 | if(parseRespSingelArray(_cmdResult,value, _iRet)) { |
| 4309 | _bRet = true; |
| 4310 | } else { |
| 4311 | _sErrorInfo = "parser resp bulk string info failed"; |
| 4312 | _bRet = false; |
| 4313 | } |
| 4314 | } else { |
| 4315 | _bRet = false; |
| 4316 | _sErrorInfo = QString("parser resp type failed:") + _cmdResult[0]; |
| 4317 | } |
| 4318 | return _bRet; |
| 4319 | } |
| 4320 | |
| 4321 | /** |
| 4322 | * 只提供了key参数,那么返回集合中的一个随机元素 |