RequestHelper:修订间差异
来自蒙纳多研究本部
MWBot |
MWBot |
||
| 第2行: | 第2行: | ||
p.language = "cn" | p.language = "cn" | ||
p.entrypoint = "http://172.19.82.27:3000" | if mw.xbdb.env() == "development" then | ||
p.entrypoint = "http://dev.xenoblade.cn:3000" | |||
else | |||
p.entrypoint = "http://172.19.82.27:3000" | |||
end | |||
local cache = {} | local cache = {} | ||
| 第21行: | 第25行: | ||
table = tablename, | table = tablename, | ||
row_id = row_id, | row_id = row_id, | ||
language = language | language = language | ||
} | } | ||
) | ) | ||
2020年6月17日 (三) 15:29的版本
此模块的文档可以在模块:RequestHelper/doc创建
local p = {}
p.language = "cn"
if mw.xbdb.env() == "development" then
p.entrypoint = "http://dev.xenoblade.cn:3000"
else
p.entrypoint = "http://172.19.82.27:3000"
end
local cache = {}
function p.post(tablename, row_id, language)
if language == nil then
language = p.language
end
local cacheKey = tablename .. ":" .. row_id .. ":" .. language
if cache[cacheKey] == nil then
cache[cacheKey] =
mw.xbdb.post(
p.entrypoint,
{
game = "xb1",
table = tablename,
row_id = row_id,
language = language
}
)
end
return cache[cacheKey]
end
return p