Skip to content

Conversation

@sonii-shivansh
Copy link

Add Performance-Optimized Constructor for Pool Configurations

Adds a new constructor to JedisPoolConfig and ConnectionPoolConfig that automatically applies the recommended performance ratio: maxTotal = maxIdle = 2 * minIdle.

The README recommends setting maxTotal = maxIdle = 2 * minIdle for best performance, but users must calculate these values manually. This enhancement makes it easier to follow best practices.

Changes

  • Added JedisPoolConfig(int minIdle) constructor with performance defaults
  • Added ConnectionPoolConfig(int minIdle) constructor with performance defaults
  • Both constructors automatically set maxIdle and maxTotal to 2 * minIdle
  • Added input validation (minIdle must be >= 1)
  • Added unit tests covering all scenarios

Usage

Before:

JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(32);
config.setMaxIdle(32);
config.setMinIdle(16);

After:

JedisPoolConfig config = new JedisPoolConfig(16);
// Automatically sets: minIdle=16, maxIdle=32, maxTotal=32

Testing

  • Added 6 new test cases per class
  • Tests cover: default constructor, custom values, edge cases, and ratio consistency

Signed-off-by: Shivansh Soni <s.soni.shivansh@gmail.com>
@sonii-shivansh sonii-shivansh force-pushed the valkey-pool-config-updates branch from ba31f54 to 039c5da Compare December 18, 2025 06:13
@yangbodong22011
Copy link
Collaborator

@sonii-shivansh Hi, thank you for this PR. However, we cannot merge it because this configuration is suitable for most scenarios, but not all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants