potentially fix redis script

This commit is contained in:
Andre Medeiros 2022-07-13 11:38:15 -04:00
parent 408c813309
commit 12435d7605

View file

@ -120,10 +120,9 @@ func SchedulerCmd(ctx context.Context) *cobra.Command {
func evalScript(ctx context.Context, redis *redis.Client) (string, error) { func evalScript(ctx context.Context, redis *redis.Client) (string, error) {
lua := fmt.Sprintf(` lua := fmt.Sprintf(`
local retv={} local retv={}
local ids=cjson.decode(ARGV[1])
for i=1, #ids do for i=1, #ARGV do
local key = KEYS[1] .. ":" .. ids[i] local key = KEYS[1] .. ":" .. ARGV[i]
if redis.call("exists", key) == 0 then if redis.call("exists", key) == 0 then
redis.call("setex", key, %.0f, 1) redis.call("setex", key, %.0f, 1)
retv[#retv + 1] = ids[i] retv[#retv + 1] = ids[i]