You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.7 KiB
96 lines
2.7 KiB
package com.fr.plugin.db.redis.core.pool; |
|
|
|
import com.fr.config.ConfigContext; |
|
import com.fanruan.api.conf.BaseConfiguration; |
|
import com.fanruan.api.conf.HolderKit; |
|
import com.fr.config.holder.Conf; |
|
|
|
|
|
/** |
|
* @author richie |
|
* @version 10.0 |
|
* Created by richie on 2019-03-21 |
|
*/ |
|
public class RedisConnectionPoolConfig extends BaseConfiguration { |
|
|
|
private static volatile RedisConnectionPoolConfig instance = null; |
|
|
|
public static RedisConnectionPoolConfig getInstance() { |
|
if (instance == null) { |
|
instance = ConfigContext.getConfigInstance(RedisConnectionPoolConfig.class); |
|
} |
|
return instance; |
|
} |
|
|
|
private static final int MAX_TOTAL = 10; |
|
private static final int MAX_IDLE = 10; |
|
private static final int MAX_WAIT = -1; |
|
private static final int TIME_OUT = 100 * 1000; |
|
|
|
private Conf<Integer> maxTotal = HolderKit.simple(MAX_TOTAL); |
|
private Conf<Integer> maxWait = HolderKit.simple(MAX_WAIT); |
|
private Conf<Integer> maxIdle = HolderKit.simple(MAX_IDLE); |
|
private Conf<Boolean> blockWhenExhausted = HolderKit.simple(true); |
|
private Conf<Boolean> lifo = HolderKit.simple(true); |
|
private Conf<Integer> timeout = HolderKit.simple(TIME_OUT); |
|
|
|
public int getMaxTotal() { |
|
return maxTotal.get(); |
|
} |
|
|
|
public void setMaxTotal(Integer maxTotal) { |
|
this.maxTotal.set(maxTotal); |
|
} |
|
|
|
public int getMaxIdle() { |
|
return maxIdle.get(); |
|
} |
|
|
|
public void setMaxIdle(int maxIdle) { |
|
this.maxIdle.set(maxIdle); |
|
} |
|
|
|
public int getMaxWait() { |
|
return maxWait.get(); |
|
} |
|
|
|
public void setMaxWait(int maxWait) { |
|
this.maxWait.set(maxWait); |
|
} |
|
|
|
public boolean getBlockWhenExhausted() { |
|
return blockWhenExhausted.get(); |
|
} |
|
|
|
public void setBlockWhenExhausted(boolean blockWhenExhausted) { |
|
this.blockWhenExhausted.set(blockWhenExhausted); |
|
} |
|
|
|
public boolean getLifo() { |
|
return lifo.get(); |
|
} |
|
|
|
public void setLifo(boolean lifo) { |
|
this.lifo.set(lifo); |
|
} |
|
|
|
public int getTimeout() { |
|
return timeout.get(); |
|
} |
|
|
|
public void setTimeout(int timeout) { |
|
this.timeout.set(timeout); |
|
} |
|
|
|
@Override |
|
public Object clone() throws CloneNotSupportedException { |
|
RedisConnectionPoolConfig cloned = (RedisConnectionPoolConfig) super.clone(); |
|
cloned.maxTotal = (Conf<Integer>) maxTotal.clone(); |
|
cloned.maxWait = (Conf<Integer>) maxWait.clone(); |
|
cloned.maxIdle = (Conf<Integer>) maxIdle.clone(); |
|
cloned.blockWhenExhausted = (Conf<Boolean>) blockWhenExhausted.clone(); |
|
cloned.lifo = (Conf<Boolean>) lifo.clone(); |
|
cloned.timeout = (Conf<Integer>) timeout.clone(); |
|
return cloned; |
|
} |
|
}
|
|
|