local iredis = require('ssp.models.iredis')
local order_id = 18622
local userlist_files = {"condition/uid/18622_1.txt", "condition/uid/18622_2.txt"} --每个txt文件大概5M
local user_lists={}
for _, file in ipairs(userlist_files) do
local res = ngx.location.capture('/backend',
{method=ngx.HTTP_GET,
table.insert(user_lists, res.body)
end
local red = iredis:new()
red:init_pipeline()
local key = "ad:o:u:" .. order_id
red:del(key)
for _, userlist in ipairs(user_lists) do
local it, err = ngx.re.gmatch(userlist, "[0-9]+")
if not it then
log(ngx.ERR, "gmatch err: ", err)
else
while true do
local m, err = it()
if err then
log(ngx.ERR, err)
break
end
if not m then
-- no match found (any more)
break
end
-- found a match
red:sadd(key, m[0])
end
end
end
red:expire(key, oneday)
local ok, err = red:commit_pipeline()