MCPcopy Create free account
hub / github.com/Tencent/Tendis / checkIfScriptExists

Method checkIfScriptExists

src/tendisplus/script/script_manager.cpp:177–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177Expected<std::string> ScriptManager::checkIfScriptExists(Session* sess) {
178 const std::vector<std::string>& args = sess->getArgs();
179 auto expdb = _svr->getSegmentMgr()->getDb(
180 sess, LUASCRIPT_DEFAULT_DBID, mgl::LockMode::LOCK_IS);
181 RET_IF_ERR_EXPECTED(expdb);
182 auto kvstore = expdb.value().store;
183 auto ptxn = kvstore->createTransaction(sess);
184 RET_IF_ERR_EXPECTED(ptxn);
185 auto& txn = ptxn.value();
186 std::stringstream ss;
187 Command::fmtMultiBulkLen(ss, args.size() - 2);
188 for (uint32_t i = 2; i < args.size(); ++i) {
189 auto tmpSha = toLower(args[i]);
190 RecordKey rk(
191 LuaScript::CHUNKID, LuaScript::DBID, RecordType::RT_META, tmpSha, "");
192 auto expStr = kvstore->getKV(rk, txn.get());
193 Command::fmtLongLong(ss, expStr.ok() ? 1 : 0);
194 }
195 return ss.str();
196}
197
198Status ScriptManager::startup(uint32_t luaStateNum) {
199 LOG(INFO) << "ScriptManager::startup begin.";

Callers 1

runMethod · 0.80

Calls 8

toLowerFunction · 0.85
getDbMethod · 0.80
getSegmentMgrMethod · 0.80
sizeMethod · 0.80
getKVMethod · 0.80
createTransactionMethod · 0.45
getMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected