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/single.ts>cachedFixedWindowLimitScript

Rate limiting library for serverless runtimes
Go to Latest
variable cachedFixedWindowLimitScript
import { cachedFixedWindowLimitScript } from "https://deno.land/x/upstash_ratelimit@v1.1.0-canary-1/src/lua-scripts/single.ts";

type

` local key = KEYS[1] local window = ARGV[1] local incrementBy = ARGV[2] -- increment rate per request at a given value, default is 1 local r = redis.call("INCRBY", key, incrementBy) if r == incrementBy then -- The first time this key is set, the value will be equal to incrementBy. -- So we only need the expire command once redis.call("PEXPIRE", key, window) end return r `