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 maxTotal = HolderKit.simple(MAX_TOTAL); private Conf maxWait = HolderKit.simple(MAX_WAIT); private Conf maxIdle = HolderKit.simple(MAX_IDLE); private Conf blockWhenExhausted = HolderKit.simple(true); private Conf lifo = HolderKit.simple(true); private Conf 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) maxTotal.clone(); cloned.maxWait = (Conf) maxWait.clone(); cloned.maxIdle = (Conf) maxIdle.clone(); cloned.blockWhenExhausted = (Conf) blockWhenExhausted.clone(); cloned.lifo = (Conf) lifo.clone(); cloned.timeout = (Conf) timeout.clone(); return cloned; } }