Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/upstash_ratelimit/src/deny-list/scripts.ts>checkDenyListScript

Rate limiting library for serverless runtimes
Latest
variable checkDenyListScript
import { checkDenyListScript } from "https://deno.land/x/upstash_ratelimit@v2.0.5-canary/src/deny-list/scripts.ts";

type

` -- Checks if values provideed in ARGV are present in the deny lists. -- This is done using the allDenyListsKey below. -- Additionally, checks the status of the ip deny list using the -- ipDenyListStatusKey below. Here are the possible states of the -- ipDenyListStatusKey key: -- * status == -1: set to "disabled" with no TTL -- * status == -2: not set, meaning that is was set before but expired -- * status > 0: set to "valid", with a TTL -- -- In the case of status == -2, we set the status to "pending" with -- 30 second ttl. During this time, the process which got status == -2 -- will update the ip deny list. local allDenyListsKey = KEYS[1] local ipDenyListStatusKey = KEYS[2] local results = redis.call('SMISMEMBER', allDenyListsKey, unpack(ARGV)) local status = redis.call('TTL', ipDenyListStatusKey) if status == -2 then redis.call('SETEX', ipDenyListStatusKey, 30, "pending") end return { results, status } `