MCPcopy Create free account
hub / github.com/cc20110101/RedisView / sort

Method sort

src/RedisView/RedisLib/RedisClient.cpp:4388–4421  ·  view source on GitHub ↗

* 返回或保存给定列表、集合、有序集合key中经过排序的元素 * @param[in] key 键 * @param[in] conditions 排序条件 * @param[out] value 结果集 * @return 成功true,失败false * @see * @note 排序默认以数字作为对象,值被解释为双精度浮点数,然后进行比较 */

Source from the content-addressed store, hash-verified

4386 * @note 排序默认以数字作为对象,值被解释为双精度浮点数,然后进行比较
4387 */
4388bool RedisClient::sort(const QString & key, QList<QByteArray> & value, const QString & conditions) {
4389 _sErrorInfo.clear();
4390 if(key.trimmed().isEmpty()) {
4391 _sErrorInfo = "key is empty";
4392 return false;
4393 }
4394
4395 _vCmdList.clear();
4396 _vCmdList.push_back("SORT");
4397 _vCmdList.push_back(key);
4398 if(!conditions.isEmpty()) {
4399 _vCmdList.push_back(conditions);
4400 }
4401
4402 _cmdResult = command(_vCmdList);
4403 if(_cmdResult[0] == '-') {
4404 if(parseRespError(_cmdResult,_sValue))
4405 _sErrorInfo = _sValue;
4406 else
4407 _sErrorInfo = "parser resp error info failed";
4408 _bRet = false;
4409 } else if(_cmdResult[0] == '*') {
4410 if(parseRespSingelArray(_cmdResult,value, _iRet)) {
4411 _bRet = true;
4412 } else {
4413 _sErrorInfo = "parser resp bulk string info failed";
4414 _bRet = false;
4415 }
4416 } else {
4417 _bRet = false;
4418 _sErrorInfo = QString("parser resp type failed:") + _cmdResult[0];
4419 }
4420 return _bRet;
4421}
4422
4423/**
4424 * 迭代当前数据库中的数据库键

Callers

nothing calls this directly

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected