Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/upstash_ratelimit/src/lua-scripts/multi.ts>fixedWindowLimitScript

Rate limiting library for serverless runtimes
Latest
variable fixedWindowLimitScript
import { fixedWindowLimitScript } from "https://deno.land/x/upstash_ratelimit@v1.2.1/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 `