import { fixedWindowLimitScript } from "https://deno.land/x/upstash_ratelimit@v2.0.5-canary/src/lua-scripts/multi.ts";
type
`
local key = KEYS[1]
local id = ARGV[1]
local window = ARGV[2]
local incrementBy = tonumber(ARGV[3])
redis.call("HSET", key, id, incrementBy)
local fields = redis.call("HGETALL", key)
if #fields == 2 and tonumber(fields[2])==incrementBy then
-- The first time this key is set, and the value will be equal to incrementBy.
-- So we only need the expire command once
redis.call("PEXPIRE", key, window)
end
return fields
`