$lua=<<<EOT
local kws={}
local lrkws={}
local nkws={}
local kw_ids={}
local lr_ids={}
local n_ids={}
for kw in string.gmatch(KEYS[1], “[^|]+”) do
table.insert(kws, “kw:”..kw)
end
for kw in string.gmatch(KEYS[2], “[^|]+”) do
table.insert(lrkws, “lrkw:”..kw)
end
for kw in string.gmatch(KEYS[3], “[^|]+”) do
table.insert(nkws, “nkw:”..kw)
end
if #kws > 0 then
kw_ids=redis.call(‘sinter’, unpack(kws))
end
if #lrkws > 0 then
lr_ids=redis.call(‘sinter’, unpack(lrkws))
end
if #nkws > 0 then
n_ids=redis.call(‘sinter’, unpack(nkws))
end
local cache_key=ARGV[1]
for _, v in ipairs(kw_ids) do
redis.call(‘sadd’, cache_key, v)
end
for _, v in ipairs(lr_ids) do
redis.call(‘sadd’, cache_key, v)
end
for _, v in ipairs(n_ids) do
redis.call(‘sadd’, cache_key, v)
end
redis.call(‘expire’, cache_key, 600)
return redis.call(‘scard’, cache_key)
EOT;
$ret=$redis->eval($lua, array(“你好|谢谢”, “”, “hello”, “cache_key”), 3);
echo $ret;