Combined approach of slidingLogs and fixedWindow with lower storage costs than slidingLogs and improved boundary behavior by calculating a weighted score between two windows.

Pro:

Good performance allows this to scale to very high loads.

Con:

Nothing major.

IMPORT_PATH: "@daiso-tech/core/rate-limiter/policies"

Implements

Constructors

Methods

  • The getExpiration method should return the expiration as Date. This method is optional, if defined rate limiter data will be cleaned up when expired. If not defined the rate limiter data will be stored forever.

    Parameters

    • _currentMetrics: Partial<Record<number, number>>
    • currentDate: Date

    Returns Date