可変数のキーで zunionstore を呼び出す必要がある lua スクリプトがあります。次のコードを実行しようとしています。
local args = redis.call("zrange", "weight", 0, -1, "WITHSCORES")
local r,w
local count = 0
local cmd = ' '
for i=1,#args,2 do
cmd = cmd .. args[i] .. ":weight " -- building up a list of zsets
count = count + 1
end
redis.call("zunionstore", "p2_test_set", count, cmd)
重要な行は次のとおりです。
cmd = cmd .. args[i] .. ":weight "
キーのリストと実際の呼び出しを作成します。
redis.call("zunionstore", "p2_test_set", count, cmd)
ただし、実行すると次のエラーが発生します。
redis-cli EVAL "$(cat p2.lua)" 0
(error) ERR Error running script (call to f_6dc6501103ea64a02798af1cc9132f8337cdcad4): @user_script:9: ERR syntax error
では、lua スクリプト内で計算された可変数のキーを redis.call("zunionstore"...) コマンドに渡すにはどうすればよいでしょうか?
前もって感謝します!