Expand description
Rate limiting cache using fixed window algorithm.
This module provides per-wallet rate limiting for:
- Order placements
- Order cancellations
- API requests
Supports both Redis (for distributed rate limiting across multiple instances) and in-memory backends (for local development without Redis).
Structsยง
- Fixed
Window ๐Counter - Fixed window counter for rate limiting (in-memory backend).
- Rate
Limit Cache - Rate limit cache using fixed window algorithm.
- Rate
Limit Info - Rate limit check result with metadata.
Enumsยง
- Rate
Limit Action - Type of rate-limited action.
- Rate
Limit Backend - Backend type for rate limiting.
- Rate
Limit Error - Error returned when rate limit is exceeded or service is unavailable.
Constantsยง
- CHECK_
AND_ ๐INCREMENT_ LUA - Lua script for atomic check-and-increment in Redis. Returns {current_count, allowed (1=yes, 0=no)}
- GET_
COUNT_ ๐LUA - Lua script to get current count without incrementing.
- REDIS_
TTL_ ๐BUFFER_ SECS - Extra TTL buffer to prevent race conditions at window boundaries (in seconds).