* 将脚本 script 添加到脚本缓存中,但并不立即执行这个脚本 * 如果给定的脚本已经在缓存里面了,那么不做动作 * @return 成功true,失败false * @see * @note */
| 3701 | * @note |
| 3702 | */ |
| 3703 | bool RedisClient::scriptload(const QString & script) { |
| 3704 | _sErrorInfo.clear(); |
| 3705 | if(script.trimmed().isEmpty()) { |
| 3706 | _sErrorInfo = "script is empty"; |
| 3707 | return false; |
| 3708 | } |
| 3709 | |
| 3710 | _vCmdList.clear(); |
| 3711 | _vCmdList.push_back("SCRIPT"); |
| 3712 | _vCmdList.push_back("LOAD"); |
| 3713 | _vCmdList.push_back(script); |
| 3714 | |
| 3715 | _cmdResult = command(_vCmdList); |
| 3716 | if(_cmdResult[0] == '-') { |
| 3717 | if(parseRespError(_cmdResult,_sValue)) |
| 3718 | _sErrorInfo = _sValue; |
| 3719 | else |
| 3720 | _sErrorInfo = "parser resp error info failed"; |
| 3721 | _bRet = false; |
| 3722 | } else if(_cmdResult[0] == '+') { |
| 3723 | if(parseRespString(_cmdResult,_sValue)) { |
| 3724 | if(_sValue == "OK") |
| 3725 | _bRet = true; |
| 3726 | else |
| 3727 | _bRet = false; |
| 3728 | } else { |
| 3729 | _sErrorInfo = "parser resp string info failed"; |
| 3730 | _bRet = false; |
| 3731 | } |
| 3732 | } else { |
| 3733 | _bRet = false; |
| 3734 | _sErrorInfo = QString("parser resp type failed:") + _cmdResult[0]; |
| 3735 | } |
| 3736 | return _bRet; |
| 3737 | } |
| 3738 | |
| 3739 | /** |
| 3740 | * 移除集合key中的一个或多个member元素,不存在的member元素会被忽略 |