Skip to content

redisPartitionLimiter

redisPartitionLimiter<T>(options): (key, source) => RateLimiterStrategy<T>

Defined in: src/redis.ts:201

limiter factory for PartitionedRateLimiterStrategy: one Redis-backed limit per partition key, shared by every instance. Evicting an idle partition only drops the local object; its count lives on in Redis until the window passes.

builder.addPartitionedRateLimiter({
partitionKey: (ctx) => ctx.properties.get('userId') as string,
limiter: redisPartitionLimiter({ client, permitLimit: 100, window: '1m', queueTimeout: '1s' }),
});
// same as: limiter: (key, s) => new RateLimiterStrategy(new RedisRateLimiter({ client, key, permitLimit, window }), opts, s)

T = any

Omit<RedisRateLimiterOptions, "key"> & PermitRateLimiterOptions

(key, source) => RateLimiterStrategy<T>