依赖包
redis.clients
jedis
3.2.0
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import javax.annotation.PostConstruct;
@Component
public class RedisUtils {
private static JedisPool[] jedisPools;
@Value("${redis.host}")
private String host;
@Value("${redis.password}")
private String password;
@Value("${redis.port}")
private String port;
@Value("${redis.maxInst}")
private Integer maxInst;
@Value("${redis.maxIdle}")
private Integer maxIdle;
@Value("${redis.maxWait}")
private Integer maxWait;
@Value("${redis.timeout}")
private Integer timeout;
@PostConstruct
public void init() {
createJedisPools();
}
private void createJedisPools() {
String[] hosts = host.split(",");
String[] ports = port.split(",");
String[] passwords = password.split(",");
jedisPools = new JedisPool[hosts.length];
JedisPoolConfig config = new JedisPoolConfig();
for (int i = 0; i
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net