add defaults to pool config
This commit is contained in:
@@ -4,145 +4,129 @@ import org.apache.commons.pool.impl.GenericObjectPool.Config;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of org.apache.commons.pool.impl.GenericObjectPool.Config that
|
* Subclass of org.apache.commons.pool.impl.GenericObjectPool.Config that
|
||||||
* includes getters/setters so it can be more easily configured by Spring
|
* includes getters/setters so it can be more easily configured by Spring and
|
||||||
* and other IoC frameworks.
|
* other IoC frameworks.
|
||||||
*
|
*
|
||||||
* Spring example:
|
* Spring example:
|
||||||
*
|
*
|
||||||
* <bean id="jedisConfig" class="redis.clients.jedis.JedisPoolConfig">
|
* <bean id="jedisConfig" class="redis.clients.jedis.JedisPoolConfig"> <property
|
||||||
* <property name="testWhileIdle" value="true"/>
|
* name="testWhileIdle" value="true"/> </bean>
|
||||||
* </bean>
|
*
|
||||||
*
|
* <bean id="jedisPool" class="redis.clients.jedis.JedisPool"
|
||||||
* <bean id="jedisPool" class="redis.clients.jedis.JedisPool" destroy-method="destroy">
|
* destroy-method="destroy"> <constructor-arg ref="jedisConfig" />
|
||||||
* <constructor-arg ref="jedisConfig" />
|
* <constructor-arg value="localhost" /> <constructor-arg type="int"
|
||||||
* <constructor-arg value="localhost" />
|
* value="6379" /> </bean>
|
||||||
* <constructor-arg type="int" value="6379" />
|
*
|
||||||
* </bean>
|
|
||||||
*
|
|
||||||
* For information on parameters refer to:
|
* For information on parameters refer to:
|
||||||
*
|
*
|
||||||
* http://commons.apache.org/pool/apidocs/org/apache/commons/pool/impl/GenericObjectPool.html
|
* http://commons.apache.org/pool/apidocs/org/apache/commons/pool/impl/
|
||||||
|
* GenericObjectPool.html
|
||||||
*/
|
*/
|
||||||
public class JedisPoolConfig extends Config
|
public class JedisPoolConfig extends Config {
|
||||||
{
|
public JedisPoolConfig() {
|
||||||
public int getMaxIdle()
|
// defaults to make your life with connection pool easier :)
|
||||||
{
|
setTestWhileIdle(true);
|
||||||
return maxIdle;
|
setMinEvictableIdleTimeMillis(60000);
|
||||||
}
|
setTimeBetweenEvictionRunsMillis(30000);
|
||||||
|
setNumTestsPerEvictionRun(-1);
|
||||||
|
}
|
||||||
|
|
||||||
public void setMaxIdle(int maxIdle)
|
public int getMaxIdle() {
|
||||||
{
|
return maxIdle;
|
||||||
this.maxIdle = maxIdle;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinIdle()
|
public void setMaxIdle(int maxIdle) {
|
||||||
{
|
this.maxIdle = maxIdle;
|
||||||
return minIdle;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setMinIdle(int minIdle)
|
public int getMinIdle() {
|
||||||
{
|
return minIdle;
|
||||||
this.minIdle = minIdle;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxActive()
|
public void setMinIdle(int minIdle) {
|
||||||
{
|
this.minIdle = minIdle;
|
||||||
return maxActive;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxActive(int maxActive)
|
public int getMaxActive() {
|
||||||
{
|
return maxActive;
|
||||||
this.maxActive = maxActive;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getMaxWait()
|
public void setMaxActive(int maxActive) {
|
||||||
{
|
this.maxActive = maxActive;
|
||||||
return maxWait;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxWait(long maxWait)
|
public long getMaxWait() {
|
||||||
{
|
return maxWait;
|
||||||
this.maxWait = maxWait;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public byte getWhenExhaustedAction()
|
public void setMaxWait(long maxWait) {
|
||||||
{
|
this.maxWait = maxWait;
|
||||||
return whenExhaustedAction;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setWhenExhaustedAction(byte whenExhaustedAction)
|
public byte getWhenExhaustedAction() {
|
||||||
{
|
return whenExhaustedAction;
|
||||||
this.whenExhaustedAction = whenExhaustedAction;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTestOnBorrow()
|
public void setWhenExhaustedAction(byte whenExhaustedAction) {
|
||||||
{
|
this.whenExhaustedAction = whenExhaustedAction;
|
||||||
return testOnBorrow;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestOnBorrow(boolean testOnBorrow)
|
public boolean isTestOnBorrow() {
|
||||||
{
|
return testOnBorrow;
|
||||||
this.testOnBorrow = testOnBorrow;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTestOnReturn()
|
public void setTestOnBorrow(boolean testOnBorrow) {
|
||||||
{
|
this.testOnBorrow = testOnBorrow;
|
||||||
return testOnReturn;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestOnReturn(boolean testOnReturn)
|
public boolean isTestOnReturn() {
|
||||||
{
|
return testOnReturn;
|
||||||
this.testOnReturn = testOnReturn;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTestWhileIdle()
|
public void setTestOnReturn(boolean testOnReturn) {
|
||||||
{
|
this.testOnReturn = testOnReturn;
|
||||||
return testWhileIdle;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestWhileIdle(boolean testWhileIdle)
|
public boolean isTestWhileIdle() {
|
||||||
{
|
return testWhileIdle;
|
||||||
this.testWhileIdle = testWhileIdle;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimeBetweenEvictionRunsMillis()
|
public void setTestWhileIdle(boolean testWhileIdle) {
|
||||||
{
|
this.testWhileIdle = testWhileIdle;
|
||||||
return timeBetweenEvictionRunsMillis;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
|
public long getTimeBetweenEvictionRunsMillis() {
|
||||||
{
|
return timeBetweenEvictionRunsMillis;
|
||||||
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumTestsPerEvictionRun()
|
public void setTimeBetweenEvictionRunsMillis(
|
||||||
{
|
long timeBetweenEvictionRunsMillis) {
|
||||||
return numTestsPerEvictionRun;
|
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
|
public int getNumTestsPerEvictionRun() {
|
||||||
{
|
return numTestsPerEvictionRun;
|
||||||
this.numTestsPerEvictionRun = numTestsPerEvictionRun;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getMinEvictableIdleTimeMillis()
|
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
|
||||||
{
|
this.numTestsPerEvictionRun = numTestsPerEvictionRun;
|
||||||
return minEvictableIdleTimeMillis;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
|
public long getMinEvictableIdleTimeMillis() {
|
||||||
{
|
return minEvictableIdleTimeMillis;
|
||||||
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public long getSoftMinEvictableIdleTimeMillis()
|
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
|
||||||
{
|
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
|
||||||
return softMinEvictableIdleTimeMillis;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis)
|
public long getSoftMinEvictableIdleTimeMillis() {
|
||||||
{
|
return softMinEvictableIdleTimeMillis;
|
||||||
this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
|
}
|
||||||
}
|
|
||||||
|
public void setSoftMinEvictableIdleTimeMillis(
|
||||||
|
long softMinEvictableIdleTimeMillis) {
|
||||||
|
this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user