Giter VIP home page Giter VIP logo

Comments (2)

dcheckoway avatar dcheckoway commented on May 8, 2024

It would be great if somehow the JedisPool exposed its Config prior to initializing, via a wrapper object that wraps around the GenericObjectPool.Config...with setters. For example, here's what we've had to do in order to work around current IOC-unfriendly limitations:

<bean id="jedisPool"
    class="redis.clients.jedis.JedisPool"
    destroy-method="destroy">
<constructor-arg>
  <bean class="redis.clients.jedis.JedisPoolConfigWrapper"
        p:maxActive="$test{redis.pool.maxActive}"
        p:maxIdle="$test{redis.pool.maxIdle}"
        p:maxWait="$test{redis.pool.maxWait}"
        p:minIdle="$test{redis.pool.minIdle}"
        p:testOnBorrow="$test{redis.pool.testOnBorrow}"
        p:testOnReturn="$test{redis.pool.testOnReturn}"
        p:testWhileIdle="$test{redis.pool.testWhileIdle}"/>
</constructor-arg>
<constructor-arg type="java.lang.String" value="$test{redis.host}"/>
<constructor-arg type="int" value="$test{redis.port}"/>
</bean>

...and here's the wrapper:

public class JedisPoolConfigWrapper extends GenericObjectPool.Config {
public boolean getLifo() {
    return lifo;
}
public void setLifo(boolean lifo) {
    this.lifo = lifo;
}

public int getMaxActive() {
    return maxActive;
}
public void setMaxActive(int maxActive) {
    this.maxActive = maxActive;
}

public int getMaxIdle() {
    return maxIdle;
}
public void setMaxIdle(int maxIdle) {
    this.maxIdle = maxIdle;
}

public long getMaxWait() {
    return maxWait;
}
public void setMaxWait(long maxWait) {
    this.maxWait = maxWait;
}

public long getMinEvictableIdleTimeMillis() {
    return minEvictableIdleTimeMillis;
}
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
    this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}

public int getMinIdle() {
    return minIdle;
}
public void setMinIdle(int minIdle) {
    this.minIdle = minIdle;
}

public int getNumTestsPerEvictionRun() {
    return numTestsPerEvictionRun;
}
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
    this.numTestsPerEvictionRun = numTestsPerEvictionRun;
}

public long getSoftMinEvictableIdleTimeMillis() {
    return softMinEvictableIdleTimeMillis;
}
public void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis) {
    this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
}

public boolean getTestOnBorrow() {
    return testOnBorrow;
}
public void setTestOnBorrow(boolean testOnBorrow) {
    this.testOnBorrow = testOnBorrow;
}

public boolean getTestOnReturn() {
    return testOnReturn;
}
public void setTestOnReturn(boolean testOnReturn) {
    this.testOnReturn = testOnReturn;
}

public boolean getTestWhileIdle() {
    return testWhileIdle;
}
public void setTestWhileIdle(boolean testWhileIdle) {
    this.testWhileIdle = testWhileIdle;
}

public long getTimeBetweenEvictionRunsMillis() {
    return timeBetweenEvictionRunsMillis;
}
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
    this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
}

public byte getWhenExhaustedAction() {
    return whenExhaustedAction;
}
public void setWhenExhaustedAction(byte whenExhaustedAction) {
    this.whenExhaustedAction = whenExhaustedAction;
}
}

from jedis.

xetorthio avatar xetorthio commented on May 8, 2024

This is done in master branch already.
https://github.com/xetorthio/jedis/blob/master/src/main/java/redis/clients/jedis/JedisPoolConfig.java#L25

Thanks!

from jedis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.