Documentation
¶
Overview ¶
Package slidingcounter implements the Sliding Window Counter rate limiting algorithm.
It calculates an estimated request volume using a weighted moving average of the current and previous window counters, providing high precision with strictly O(1) memory footprint.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Strategy ¶
type Strategy struct{}
Strategy implements the algorithm.Algorithm interface for Sliding Window Counter.
func New ¶
func New() *Strategy
New creates a new instance of the Sliding Window Counter algorithm strategy.
func (*Strategy) EvaluateMemory ¶
func (s *Strategy) EvaluateMemory(now time.Time, state *algorithm.State, limit int64, window time.Duration) algorithm.Result
EvaluateMemory evaluates the sliding window counter rate limit state synchronously in RAM.
func (*Strategy) RedisScript ¶
RedisScript returns the high-performance atomic Lua script for Redis execution.
Click to show internal directories.
Click to hide internal directories.