org.springframework.data.redis.connection.RedisPassword Java Examples

The following examples show how to use org.springframework.data.redis.connection.RedisPassword. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisConfig.java    From charging_pile_cloud with MIT License 6 votes vote down vote up
@Bean
JedisConnectionFactory jedisConnectionFactory2() {
    RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration ();
    redisStandaloneConfiguration.setHostName(redisProperties.getHost());
    redisStandaloneConfiguration.setPort(redisProperties.getPort());
    redisStandaloneConfiguration.setPassword(RedisPassword.of(redisProperties.getPassword()));
    redisStandaloneConfiguration.setDatabase(RedisDbIndexConst.DB_INDEX_2);
    JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfiguration = JedisClientConfiguration.builder();

    JedisConnectionFactory factory = new JedisConnectionFactory(redisStandaloneConfiguration,
            jedisClientConfiguration.usePooling().poolConfig(jedisPoolConfig()).build());
    return factory;
}
 
Example #2
Source File: RedisConfig.java    From charging_pile_cloud with MIT License 5 votes vote down vote up
@Bean
@Primary
JedisConnectionFactory jedisConnectionFactory() {
    RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration ();
    redisStandaloneConfiguration.setHostName(redisProperties.getHost());
    redisStandaloneConfiguration.setPort(redisProperties.getPort());
    redisStandaloneConfiguration.setPassword(RedisPassword.of(redisProperties.getPassword()));
    redisStandaloneConfiguration.setDatabase(RedisDbIndexConst.DB_INDEX_DEFAULT);
    JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfiguration = JedisClientConfiguration.builder();

    JedisConnectionFactory factory = new JedisConnectionFactory(redisStandaloneConfiguration,
            jedisClientConfiguration.usePooling().poolConfig(jedisPoolConfig()).build());
    return factory;
}
 
Example #3
Source File: RedisConfig.java    From charging_pile_cloud with MIT License 5 votes vote down vote up
@Bean
JedisConnectionFactory jedisConnectionFactory1() {
    RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration ();
    redisStandaloneConfiguration.setHostName(redisProperties.getHost());
    redisStandaloneConfiguration.setPort(redisProperties.getPort());
    redisStandaloneConfiguration.setPassword(RedisPassword.of(redisProperties.getPassword()));
    redisStandaloneConfiguration.setDatabase(RedisDbIndexConst.DB_INDEX_1);
    JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfiguration = JedisClientConfiguration.builder();

    JedisConnectionFactory factory = new JedisConnectionFactory(redisStandaloneConfiguration,
            jedisClientConfiguration.usePooling().poolConfig(jedisPoolConfig()).build());
    return factory;
}
 
Example #4
Source File: RedisConfig.java    From charging_pile_cloud with MIT License 5 votes vote down vote up
@Bean
JedisConnectionFactory jedisConnectionFactory3() {
    RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration ();
    redisStandaloneConfiguration.setHostName(redisProperties.getHost());
    redisStandaloneConfiguration.setPort(redisProperties.getPort());
    redisStandaloneConfiguration.setPassword(RedisPassword.of(redisProperties.getPassword()));
    redisStandaloneConfiguration.setDatabase(RedisDbIndexConst.DB_INDEX_3);
    JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfiguration = JedisClientConfiguration.builder();

    JedisConnectionFactory factory = new JedisConnectionFactory(redisStandaloneConfiguration,
            jedisClientConfiguration.usePooling().poolConfig(jedisPoolConfig()).build());
    return factory;
}
 
Example #5
Source File: RedisAutoConfig.java    From unimall with Apache License 2.0 5 votes vote down vote up
@Bean
public RedisStandaloneConfiguration userRedisConfig() {
    RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
    config.setHostName(host);
    config.setPassword(RedisPassword.of(password));
    config.setPort(port);
    config.setDatabase(database);
    return config;
}
 
Example #6
Source File: RedisAutoConfig.java    From unimall with Apache License 2.0 5 votes vote down vote up
@Bean
public RedisStandaloneConfiguration lockRedisConfig() {
    RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
    config.setHostName(host);
    config.setPassword(RedisPassword.of(password));
    config.setPort(port);
    config.setDatabase(database);
    return config;
}
 
Example #7
Source File: RedisAutoConfig.java    From unimall with Apache License 2.0 5 votes vote down vote up
@Bean
public RedisStandaloneConfiguration defaultRedisConfig() {
    RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
    config.setHostName(host);
    config.setPassword(RedisPassword.of(password));
    config.setPort(port);
    config.setDatabase(database);
    return config;
}
 
Example #8
Source File: RateLimiterPluginDataHandler.java    From soul with Apache License 2.0 5 votes vote down vote up
private RedisClusterConfiguration redisClusterConfiguration(final RateLimiterConfig rateLimiterConfig) {
    RedisClusterConfiguration config = new RedisClusterConfiguration();
    config.setClusterNodes(createRedisNode(rateLimiterConfig.getUrl()));
    if (rateLimiterConfig.getPassword() != null) {
        config.setPassword(RedisPassword.of(rateLimiterConfig.getPassword()));
    }
    return config;
}
 
Example #9
Source File: RateLimiterPluginDataHandler.java    From soul with Apache License 2.0 5 votes vote down vote up
private RedisSentinelConfiguration redisSentinelConfiguration(final RateLimiterConfig rateLimiterConfig) {
    RedisSentinelConfiguration config = new RedisSentinelConfiguration();
    config.master(rateLimiterConfig.getMaster());
    config.setSentinels(createRedisNode(rateLimiterConfig.getUrl()));
    if (rateLimiterConfig.getPassword() != null) {
        config.setPassword(RedisPassword.of(rateLimiterConfig.getPassword()));
    }
    config.setDatabase(rateLimiterConfig.getDatabase());
    return config;
}
 
Example #10
Source File: RedisConfig.java    From ueboot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * spring boot 2.0后采用Lettuce作为redis调用客户端
 * 默认配置只支持单机模式,如需要其他模式,需要另外定义
 *
 * @return LettuceConnectionFactory
 */
@Bean
@ConditionalOnMissingBean(type = {"org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory"})
public LettuceConnectionFactory redisConnectionFactory(RedisProperties redisProperties) {
    RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(redisProperties.getHost(),
            redisProperties.getPort());
    configuration.setDatabase(redisProperties.getDatabase());
    configuration.setPassword(RedisPassword.of(redisProperties.getPassword()));
    return new LettuceConnectionFactory(configuration);
}
 
Example #11
Source File: RedisCacheConfig.java    From SpringBootBucket with MIT License 5 votes vote down vote up
@Bean
public LettuceConnectionFactory redisConnectionFactory() {
    RedisStandaloneConfiguration redisConf = new RedisStandaloneConfiguration();
    redisConf.setHostName(env.getProperty("spring.redis.host"));
    redisConf.setPort(Integer.parseInt(env.getProperty("spring.redis.port")));
    redisConf.setPassword(RedisPassword.of(env.getProperty("spring.redis.password")));
    return new LettuceConnectionFactory(redisConf);
}
 
Example #12
Source File: RedisConfig.java    From FEBS-Security with Apache License 2.0 5 votes vote down vote up
@Bean
JedisConnectionFactory jedisConnectionFactory() {
    RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
    redisStandaloneConfiguration.setHostName(host);
    redisStandaloneConfiguration.setPort(port);
    redisStandaloneConfiguration.setPassword(RedisPassword.of(password));
    redisStandaloneConfiguration.setDatabase(database);

    JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfiguration = JedisClientConfiguration.builder();
    jedisClientConfiguration.connectTimeout(Duration.ofMillis(timeout));
    jedisClientConfiguration.usePooling();
    return new JedisConnectionFactory(redisStandaloneConfiguration, jedisClientConfiguration.build());
}
 
Example #13
Source File: Redis.java    From syncer with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public LettuceConnectionFactory getConnectionFactory() {
  if (clusterConnection.valid()) {
    return new LettuceConnectionFactory(clusterConnection.getConfig());
  }
  if (connection.valid()) {
    RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration(
        connection.getAddress(),
        connection.getPort());
    if (!connection.noPassword()) {
      standaloneConfig.setPassword(RedisPassword.of(connection.getPassword()));
    }
    return new LettuceConnectionFactory(standaloneConfig);
  }
  throw new InvalidConfigException("No valid connection configured");
}
 
Example #14
Source File: RedisConfig.java    From spring-boot-start-current with Apache License 2.0 5 votes vote down vote up
@Bean
  public RedisConnectionFactory redisConnectionFactory () {
RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration(  );
standaloneConfig.setHostName( host );
standaloneConfig.setPort( port );
standaloneConfig.setPassword( RedisPassword.of( password ) );
standaloneConfig.setDatabase( database );
      return new JedisConnectionFactory(standaloneConfig);
  }
 
Example #15
Source File: RedisUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
private static void enrichRedisConfiguration(final RedisConfiguration redisConfiguration,
                                             final Integer dbIndex,
                                             final String password) {
    if (redisConfiguration instanceof RedisConfiguration.WithDatabaseIndex) {
        ((RedisConfiguration.WithDatabaseIndex) redisConfiguration).setDatabase(dbIndex);
    }
    if (redisConfiguration instanceof RedisConfiguration.WithPassword) {
        ((RedisConfiguration.WithPassword) redisConfiguration).setPassword(RedisPassword.of(password));
    }
}
 
Example #16
Source File: RedisClusterConnection.java    From syncer with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public RedisClusterConfiguration getConfig() {
  RedisClusterConfiguration configuration = new RedisClusterConfiguration(
      getClusterNodes());
  configuration.setPassword(RedisPassword.of(getPassword()));
  return configuration;
}