mokies/ratelimitj

RedisRateLimiterFactory should be able to work with just a connection (rather than a RedisClient)

Opened this issue · 0 comments

The RedisClient docs say:

RedisClient is an expensive resource. It holds a set of netty's EventLoopGroup's that use multiple threads. Reuse this instance as much as possible or share a ClientResources instance amongst multiple client instances.

RedisRateLimiterFactory makes it difficult to share a single RedisClient, because its close() method closes the client. (That is, it effectively "takes ownership" of the client.)

Taking a RedisClient also makes it incompatible with connection pooling, as typically one does not have visibility to the RedisClient itself outside of the pool's construction.

Given that RedisRateLimiterFactory only uses a single connection, could an additional constructor that takes a StatefulRedisConnection<String, String> be added?