I use Spring RedisTemplate (spring-data-redis 1.7.1) for communication with Redis. I need to get and then delete keys by regexp (ex: "context:user1:*"). I use method "RedisTemplate.keys(...)" for getting array of keys
{
String key = String.format("%s:%s:%s", context, userId,"*");
Set<byte[]> keys = redisTemplate.getConnectionFactory().getConnection().keys(key.getBytes());
logger.debug(String.format("test log"));
}
But on 8-9 iteration call restTemplates.keys(...) stops execution of the my java service. The call of method is not returned from framework. My service is hangs up. Also it is happening everytime. Workaround is only restart my service.
Assuming you're using Jedis with pooling, you run into an exhaustion of the underlying connection pool.
Each call to redisTemplate.getConnectionFactory().getConnection()
allocates a new connection from the connection pool. Do you call connection.close()
?. If not, the pool gets exhausted. The pools starts to block your request (hoping another thread will return a connection so it can be used by the thread which requests a connection).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With