JedisPoolConfig config =
new
JedisPoolConfig();
// Whether the connection is blocked when the connection is exhausted. If it is false, an exception is reported. If it is true, the connection is blocked until it times out. The default value is true.
config.setBlockWhenExhausted(
true
);
// Set the eviction policy class name. The default value is defaultevictionpolicy (when the connection time exceeds the maximum idle time or the number of connections exceeds the maximum number of idle connections)
config.setEvictionPolicyClassName(
"org.apache.commons.pool2.impl.DefaultEvictionPolicy"
);
// Whether to enable the pool JMX management function. The default value is true.
config.setJmxEnabled(
true
);
// Mbean objectname = new objectname ("org. apache. commons. pool2: TYPE = genericobjectpool, name = "+" pool "+ I); Mo thinks that" pool ", JMX is not familiar, but I don't know what it is... the default value is good.
config.setJmxNamePrefix(
"pool"
);
// Whether to enable post-import/export. The default value is true.
config.setLifo(
true
);
// Maximum number of idle connections. The default value is 8.
config.setMaxIdle(
8
);
// Maximum number of connections. The default value is 8.
config.setMaxTotal(
8
);
// Obtain the maximum number of waiting milliseconds for the connection (if blockwhenexhausted is set to block). If it times out, an exception is thrown. If it is less than zero, the default value is-1.
config.setMaxWaitMillis(-
1
);
// The minimum idle time of the eviction connection is 1800000 milliseconds by default (30 minutes)
config.setMinEvictableIdleTimeMillis(
1800000
);
// The minimum number of idle connections. The default value is 0.
config.setMinIdle(
0
);
// The maximum number of evicted objects during each eviction check. If the value is negative, 1/ABS (n). The default value is 3.
config.setNumTestsPerEvictionRun(
3
);
// How long will the object be evicted after it is idle? If the idle time is greater than this value and the idle connection is greater than the maximum number of idle connections, the object will be evicted without being determined based on minevictableidletimemillis (default eviction policy)
config.setSoftMinEvictableIdleTimeMillis(
1800000
);
// Check the validity when obtaining the connection. The default value is false.
config.setTestOnBorrow(
false
);
// Check validity when idle. The default value is false.
config.setTestWhileIdle(
false
);
// The time interval (in milliseconds) of the eviction scan. If the value is negative, the eviction thread is not run. The default value is-1.
config.setTimeBetweenEvictionRunsMillis(-
1
);
JedisPool pool =
new
JedisPool(config,
"localhost",
);
Int timeout = 3000; new jedissentinelpool (master, sentinels, poolconfig, timeout); // timeout read timeout
Redis-jedispoolconfig Configuration