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

Method append

src/RedisView/RedisLib/RedisClient.cpp:690–719  ·  view source on GitHub ↗

* 如果key已经存在并且是一个字符串,APPEND命令将value追加到key原来的值的末尾 * 如果key不存在,APPEND就简单地将给定key设为value,就像执行SET key value一样 * @param[in] key 一个或多个键 * @param[in] value 追加的值 * @return 追加value之后,key中字符串的长度 * @see * @note */

Source from the content-addressed store, hash-verified

688 * @note
689 */
690qlonglong RedisClient::append(const QString & key, const QString & value) {
691 _sErrorInfo.clear();
692 if(key.trimmed().isEmpty()) {
693 _sErrorInfo = "key is empty";
694 return false;
695 }
696
697 _vCmdList.clear();
698 _vCmdList.push_back("APPEND");
699 _vCmdList.push_back("key");
700 _vCmdList.push_back(value);
701
702 _cmdResult = command(_vCmdList);
703 if(_cmdResult[0] == '-') {
704 if(parseRespError(_cmdResult,_sValue))
705 _sErrorInfo = _sValue;
706 else
707 _sErrorInfo = "parser resp error info failed";
708 _llRet = 0;
709 } else if(_cmdResult[0] == ':') {
710 if(!parseRespInteger(_cmdResult,_llRet)) {
711 _sErrorInfo = "parser resp integer info failed";
712 _llRet = 0;
713 }
714 } else {
715 _bRet = false;
716 _sErrorInfo = QString("parser resp type failed:") + _cmdResult[0];
717 }
718 return _llRet;
719}
720
721/**
722 * 返回当前数据库的key的数量

Callers 15

isClusterMethod · 0.80
getReplicationInfoMethod · 0.80
getRedisInfoMethod · 0.80
isMasterMethod · 0.80
getClusterSlotsMethod · 0.80
getClusterNodesMethod · 0.80
dbsizeMethod · 0.80
scriptflushMethod · 0.80
scriptkillMethod · 0.80
getcfgMethod · 0.80
selectMethod · 0.80
clusterCommandMethod · 0.80

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected