当前位置: 首页>>代码示例>>Java>>正文


Java JedisConnectionFactory.setDatabase方法代码示例

本文整理汇总了Java中org.springframework.data.redis.connection.jedis.JedisConnectionFactory.setDatabase方法的典型用法代码示例。如果您正苦于以下问题:Java JedisConnectionFactory.setDatabase方法的具体用法?Java JedisConnectionFactory.setDatabase怎么用?Java JedisConnectionFactory.setDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.redis.connection.jedis.JedisConnectionFactory的用法示例。


在下文中一共展示了JedisConnectionFactory.setDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jedisConnConfig

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
private void jedisConnConfig(final JedisConnectionFactory jedisConnectionFactory) {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    try {
        poolConfig.setMaxTotal(Integer.parseInt(REDIS_MAXTOTAL.getValue()));
        poolConfig.setMaxIdle(Integer.parseInt(REDIS_MAXIDLE.getValue()));
        poolConfig.setBlockWhenExhausted(true);
        if (!"".equals(REDIS_PASSWORD.getValue())) {
            jedisConnectionFactory.setPassword(REDIS_PASSWORD.getValue());
        }
        if (!"".equals(REDIS_DATABASE.getValue())) {
            jedisConnectionFactory.setDatabase(Integer.parseInt(REDIS_DATABASE.getValue()));
        }
        jedisConnectionFactory.setPoolConfig(poolConfig);
        jedisConnectionFactory.setUsePool(true);
        jedisConnectionFactory.setTimeout(Integer.parseInt(REDIS_TIMEOUT.getValue()));
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
 
开发者ID:globocom,项目名称:groot,代码行数:20,代码来源:RedisConfiguration.java

示例2: 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;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:19,代码来源:RedisTicketRegistryConfiguration.java

示例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);
        }
    }
}
 
开发者ID:Fourwenwen,项目名称:consistent-hashing-redis,代码行数:24,代码来源:HwRedisConnectionFactory.java

示例4: clientConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Primary
@Bean("clientConnectionFactory")
RedisConnectionFactory clientConnectionFactory() {
	JedisConnectionFactory factory = new JedisConnectionFactory();
	factory.setDatabase(CLIENT_DB_INDEX);
	return factory;
}
 
开发者ID:PatternFM,项目名称:tokamak,代码行数:8,代码来源:RedisConfiguration.java

示例5: redisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean
public RedisConnectionFactory redisConnectionFactory () {
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName( host );
    jedisConnectionFactory.setPort( port );
    jedisConnectionFactory.setPassword( password );
    jedisConnectionFactory.setDatabase( database );
    return jedisConnectionFactory;
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:10,代码来源:RedisConfig.java

示例6: getRedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
private RedisConnectionFactory getRedisConnectionFactory(int database, String host, String password, int port, int maxIdle, int minIdle, int maxWait) {
    JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
    connectionFactory.setDatabase(database);
    connectionFactory.setHostName(host);
    connectionFactory.setPassword(password);
    connectionFactory.setPort(port);
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxIdle(maxIdle);
    poolConfig.setMinIdle(minIdle);
    poolConfig.setMaxWaitMillis(maxWait);
    poolConfig.setTestOnBorrow(true);
    poolConfig.setTestOnCreate(true);
    poolConfig.setTestWhileIdle(true);
    connectionFactory.setUsePool(true);
    return connectionFactory;
}
 
开发者ID:slking1987,项目名称:mafia,代码行数:17,代码来源:RedisConfig.java

示例7: applyProperties

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
protected final JedisConnectionFactory applyProperties(
		JedisConnectionFactory factory) {
	factory.setHostName(this.properties.getHost());
	factory.setPort(this.properties.getPort());
	if (this.properties.getPassword() != null) {
		factory.setPassword(this.properties.getPassword());
	}
	factory.setDatabase(this.properties.getDatabase());
	if (this.properties.getTimeout() > 0) {
		factory.setTimeout(this.properties.getTimeout());
	}
	return factory;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:RedisAutoConfiguration.java

示例8: userRedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Primary
@Bean(name = "userRedisConnectionFactory")
public RedisConnectionFactory userRedisConnectionFactory() {
    JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
    redisConnectionFactory.setHostName(userRedisProperty.getHost());
    redisConnectionFactory.setPort(userRedisProperty.getPort());
    redisConnectionFactory.setDatabase(userRedisProperty.getDatabase());
    return redisConnectionFactory;
}
 
开发者ID:idreamshen,项目名称:spring-boot-with-multi-redis,代码行数:10,代码来源:RedisConfiguration.java

示例9: roleRedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean(name = "roleRedisConnectionFactory")
public RedisConnectionFactory roleRedisConnectionFactory() {
    JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
    redisConnectionFactory.setHostName(roleRedisProperty.getHost());
    redisConnectionFactory.setPort(roleRedisProperty.getPort());
    redisConnectionFactory.setDatabase(roleRedisProperty.getDatabase());
    return redisConnectionFactory;
}
 
开发者ID:idreamshen,项目名称:spring-boot-with-multi-redis,代码行数:9,代码来源:RedisConfiguration.java

示例10: connectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean
public JedisConnectionFactory connectionFactory(JedisPoolConfig jedisPoolConfig) {
    JedisConnectionFactory connection = new JedisConnectionFactory();
    connection.setHostName(getPropertyFormEnv("redis.host"));
    connection.setPort(getIntPropertyFormEnv("redis.port"));
    connection.setTimeout(getIntPropertyFormEnv("redis.timeout"));
    connection.setDatabase(getIntPropertyFormEnv("redis.database"));
    connection.setPoolConfig(jedisPoolConfig);
    return connection;
}
 
开发者ID:izhangzhihao,项目名称:SpringMVCWithJavaConfig,代码行数:11,代码来源:RedisConfig.java

示例11: applyProperties

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
protected final JedisConnectionFactory applyProperties(
		JedisConnectionFactory factory) {
	configureConnection(factory);
	if (this.properties.isSsl()) {
		factory.setUseSsl(true);
	}
	factory.setDatabase(this.properties.getDatabase());
	if (this.properties.getTimeout() > 0) {
		factory.setTimeout(this.properties.getTimeout());
	}
	return factory;
}
 
开发者ID:easycodebox,项目名称:easycode,代码行数:13,代码来源:ShiroRedisAutoConfiguration.java

示例12: redisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean
public RedisConnectionFactory redisConnectionFactory() {
    final JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName(env.getProperty("wtfdyum.redis.server"));
    jedisConnectionFactory.setPort(env.getProperty("wtfdyum.redis.port", Integer.class));
    jedisConnectionFactory.setDatabase(env.getProperty("wtfdyum.redis.database", Integer.class));
    return jedisConnectionFactory;
}
 
开发者ID:jchampemont,项目名称:WTFDYUM,代码行数:9,代码来源:RedisConfiguration.java

示例13: createConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Override
protected RedisConnectionFactory createConnectionFactory( RedisShardSpec shardSpec ) {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(shardSpec.getHost());
    factory.setPort(shardSpec.getPort());
    factory.setDatabase(shardSpec.getDb());
    factory.afterPropertiesSet();
    return factory;
}
 
开发者ID:Dennyss,项目名称:sharded-spring-data-redis,代码行数:10,代码来源:JedisShardedConnectionFactoryProvider.java

示例14: applyProperties

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
protected final JedisConnectionFactory applyProperties(JedisConnectionFactory factory) {
	factory.setHostName(hostname);
	factory.setPort(port);
	if (StringUtils.hasText(password)) {
		factory.setPassword(password);
	}
	factory.setDatabase(database);
	return factory;
}
 
开发者ID:spring-projects,项目名称:spring-xd-samples,代码行数:10,代码来源:RedisSourceConfiguration.java

示例15: accountConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean("accountConnectionFactory")
RedisConnectionFactory accountConnectionFactory() {
	JedisConnectionFactory factory = new JedisConnectionFactory();
	factory.setDatabase(ACCOUNT_DB_INDEX);
	return factory;
}
 
开发者ID:PatternFM,项目名称:tokamak,代码行数:7,代码来源:RedisConfiguration.java


注:本文中的org.springframework.data.redis.connection.jedis.JedisConnectionFactory.setDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。