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