← Alle Concepts
pattern·team·rate_limits_pg

Rate limits in Postgres

Atomic upsert with case-reset. No Redis needed for low-volume SaaS.

CREATE TABLE rate_limit_buckets(key TEXT PRIMARY KEY, count INT, reset_at TIMESTAMPTZ). UPSERT with `count = CASE WHEN NOW() > reset_at THEN 1 ELSE count + 1 END`. Use Memory-fallback for tests so unit tests don't need a DB.

Beziehungen

Outgoing
rate-limitpatternteam