本文整理匯總了Java中org.springframework.data.redis.connection.jedis.JedisConnectionFactory.setPort方法的典型用法代碼示例。如果您正苦於以下問題:Java JedisConnectionFactory.setPort方法的具體用法?Java JedisConnectionFactory.setPort怎麽用?Java JedisConnectionFactory.setPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.data.redis.connection.jedis.JedisConnectionFactory
的用法示例。
在下文中一共展示了JedisConnectionFactory.setPort方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: redisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
@RefreshScope
public RedisConnectionFactory redisConnectionFactory() {
final RedisTicketRegistryProperties redis = casProperties.getTicket().getRegistry().getRedis();
final JedisPoolConfig poolConfig = redis.getPool() != null ? jedisPoolConfig() : new JedisPoolConfig();
final JedisConnectionFactory factory = new JedisConnectionFactory(poolConfig);
factory.setHostName(redis.getHost());
factory.setPort(redis.getPort());
if (redis.getPassword() != null) {
factory.setPassword(redis.getPassword());
}
factory.setDatabase(redis.getDatabase());
if (redis.getTimeout() > 0) {
factory.setTimeout(redis.getTimeout());
}
return factory;
}
示例2: redisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public RedisConnectionFactory redisConnectionFactory() {
String default_host = "localhost";
int port = 6379;
String host = null;
{ // setup the host using the env vars
host = System.getenv().get(SELDON_CLUSTER_MANAGER_REDIS_HOST_KEY);
if (host == null) {
logger.error(String.format("FAILED to find env var [%s]", SELDON_CLUSTER_MANAGER_REDIS_HOST_KEY));
host = default_host;
}
}
logger.info(String.format("setting up connection factory, host[%s] port[%d]", host, port));
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
jedisConnectionFactory.setHostName(host);
jedisConnectionFactory.setPort(port);
jedisConnectionFactory.setPassword("");
jedisConnectionFactory.setUsePool(true);
jedisConnectionFactory.setPoolConfig(new JedisPoolConfig());
return jedisConnectionFactory;
}
示例3: afterPropertiesSet
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Override
public void afterPropertiesSet() throws Exception {
int redisCount = Integer.parseInt(RedisProperties.getPropertie("redis.count").toString());
factories = new ArrayList<JedisConnectionFactory>(redisCount);
for (int i = 0; i < redisCount; i++) {
int dbSize = 1;
Object dbSizeObj = RedisProperties.getPropertie("redis.db.size" + i);
if (dbSizeObj != null) {
dbSize = Integer.valueOf(dbSizeObj.toString());
}
for (int j = 0; j < dbSize; j++) {
JedisConnectionFactory factory = new JedisConnectionFactory(sentinelConfig,poolConfig);
factory.setHostName(RedisProperties.getPropertie("redis.host" + i).toString());
factory.setPort(Integer.parseInt(RedisProperties.getPropertie("redis.port" + i).toString()));
factory.setPassword(RedisProperties.getPropertie("reids.passwd" + i).toString());
factory.setTimeout(Integer.parseInt(RedisProperties.getPropertie("redis.timeout").toString()));
factory.setDatabase(j);
// 執行必要方法
factory.afterPropertiesSet();
factories.add(factory);
}
}
}
示例4: jedisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
JedisConnectionFactory jedisConnectionFactory() {
JedisConnectionFactory factory = new JedisConnectionFactory();
factory.setHostName(redisHost);
factory.setPort(redisPort);
factory.setUsePool(true);
if(StringUtils.isNotBlank(password)) {
factory.setPassword(password);
}
JedisPoolConfig config = new JedisPoolConfig();
if(maxIdle!=null) {
config.setMaxIdle(maxIdle);
}
factory.setPoolConfig(config);
return factory;
}
示例5: createRedisConnection
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
protected void createRedisConnection(String name, String host, int port, String password) {
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setHostName(host);
connectionFactory.setPort(port);
if(!StringUtils.isEmpty(password))
connectionFactory.setPassword(password);
connectionFactory.afterPropertiesSet();
RedisTemplate redisTemplate = new MyStringRedisTemplate();
redisTemplate.setConnectionFactory(connectionFactory);
redisTemplate.afterPropertiesSet();
RedisApplication.redisTemplatesMap.put(name, redisTemplate);
Map<String, Object> redisServerMap = new HashMap<String, Object>();
redisServerMap.put("name", name);
redisServerMap.put("host", host);
redisServerMap.put("port", port);
redisServerMap.put("password", password);
RedisApplication.redisServerCache.add(redisServerMap);
initRedisKeysCache(redisTemplate, name);
RedisZtreeUtil.initRedisNavigateZtree(name);
}
示例6: configureConnectionFromUrl
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
private void configureConnectionFromUrl(JedisConnectionFactory factory) {
String url = this.properties.getUrl();
if (url.startsWith("rediss://")) {
factory.setUseSsl(true);
}
try {
URI uri = new URI(url);
factory.setHostName(uri.getHost());
factory.setPort(uri.getPort());
if (uri.getUserInfo() != null) {
String password = uri.getUserInfo();
int index = password.lastIndexOf(":");
if (index >= 0) {
password = password.substring(index + 1);
}
factory.setPassword(password);
}
}
catch (URISyntaxException ex) {
throw new IllegalArgumentException("Malformed 'spring.redis.url' " + url,
ex);
}
}
示例7: createJedisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
/**
* 建立
*
* i=0, port(6379)
*
* i=1, port(6379)+i=6380
*
* @param i
* @param jedisPoolConfig
* @return
*/
protected JedisConnectionFactory createJedisConnectionFactory(int i, JedisPoolConfig jedisPoolConfig)
throws Exception {
JedisConnectionFactory result = new JedisConnectionFactory();
String hostName = extendedProperties.getString(HOSTNAME, DEFAULT_HOSTNAME);
//
int port = extendedProperties.getInt(PORT, DEFAULT_PORT);
port += i;
LOGGER.info("redis[" + i + "]: " + hostName + ":" + port);
//
result.setHostName(hostName);
result.setPort(port);
//
result.setPassword(extendedProperties.getString(PASSWORD, DEFAULT_PASSWORD));
//
result.setPoolConfig(jedisPoolConfig);
result.afterPropertiesSet();
//
return result;
}
示例8: connectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
/**
*redis 單例
* @param poolConfig
* @return
*/
@Bean(name = "connectionFactory")
public RedisConnectionFactory connectionFactory(
JedisPoolConfig poolConfig){
JedisConnectionFactory jcf=new JedisConnectionFactory();
jcf.setHostName(this.host);
jcf.setPort(this.port);
jcf.setTimeout(timeout);
// jcf.setPassword(this.password);
jcf.setPoolConfig(poolConfig);
return jcf;
}
示例9: sentinelConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
/**
*redis 主從
* @return
*/
@Bean(name="sentinelConnectionFactory")
public RedisConnectionFactory sentinelConnectionFactory(
JedisPoolConfig poolConfig,
RedisSentinelConfiguration sentinelConfig){
if(sentinelConfig!=null){
JedisConnectionFactory jcf=new JedisConnectionFactory(sentinelConfig,poolConfig);
jcf.setHostName(this.host);
jcf.setPort(this.port);
jcf.setTimeout(timeout);
// jcf.setPassword(this.password);
return jcf;
}
return connectionFactory(poolConfig);
}
示例10: jedisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
redisConnectionFactory.setHostName(redisIp);
redisConnectionFactory.setPort(6379);
return redisConnectionFactory;
}
示例11: jedisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public JedisConnectionFactory jedisConnectionFactory () {
JedisConnectionFactory jedisFactory = new JedisConnectionFactory();
jedisFactory.setPassword(redisPassword);
jedisFactory.setHostName(redisHost);
jedisFactory.setPort(redisPort);
jedisFactory.setUsePool(true);
return jedisFactory;
}
示例12: jedisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
JedisConnectionFactory jedisConnectionFactory() {
JedisConnectionFactory jedisConFactory = new JedisConnectionFactory();
jedisConFactory.setHostName(host);
jedisConFactory.setPort(port);
return jedisConFactory;
}
示例13: jedisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
JedisConnectionFactory jedisConnectionFactory(@Value("${backend.redis-service.url}") String redisEndpoint) throws URISyntaxException {
URI uri = new URI(redisEndpoint);
JedisConnectionFactory factory = new JedisConnectionFactory();
factory.setHostName(uri.getHost());
factory.setPort(uri.getPort());
return factory;
}
示例14: jedisConnectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
JedisConnectionFactory jedisConnectionFactory() {
JedisConnectionFactory factory = new JedisConnectionFactory();
factory.setHostName(redisProperties.getHost());
factory.setPort(redisProperties.getPort());
factory.setPassword(redisProperties.getPassword());
factory.setUsePool(true);
return factory;
}
示例15: connectionFactory
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public RedisConnectionFactory connectionFactory() {
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
jedisConnectionFactory.setHostName(host);
jedisConnectionFactory.setPort(port);
jedisConnectionFactory.setPassword(password);
return jedisConnectionFactory;
}