PPTV
PPTV

Reputation: 1

Spring-data-redis with redis after a while get Exception: could not get a resource from the pool

I'm using spring-data-redis to access redis(one machine) with xml config file, on beginning, everything is ok, but after some minutes, i run my test again, i got "could not get a resource from the pool" exception, i haved searched some answers, i guess this reason is the connections did

not return to the pool, how to solve this problem, why this problem can be occur, i'm using redis-3.2.6 spring-data-redis1.8 jedis2.9, below is my config

#Redis settings
redis.host=27.57.100.3
redis.port=6379
redis.pass=

maxTotal=5
maxIdle=3
minIdle=1
maxWaitMillis=10000
testOnBorrow=true
testOnReturn=true
testWhileIdle=true
timeBetweenEvictionRunsMillis=30000
numTestsPerEvictionRun=10
minEvictableIdleTimeMillis=60000
softMinEvictableIdleTimeMillis=10000
blockWhenExhausted=true

And here is my code :

@Autowired
StringRedisTemplate stringRedisTemplate

@Test
public void test(){
    ValueOperations<String, String> vop = stringRedisTemplate.opsForValue();
    String k = "k";
    String v = "v";
    vop.set(k, v);
    String value = vop.get(k);
}

Upvotes: 0

Views: 358

Answers (1)

hugo
hugo

Reputation: 45

maxTotal=5, I thought 5 is too small, you can set it to e.g,20.

Upvotes: -1

Related Questions