org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration Java Examples

The following examples show how to use org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration. 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 SpringMVC-Project with MIT License 8 votes vote down vote up
@Bean
public LettuceConnectionFactory redisConnectionFactory() {
    RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
    redisStandaloneConfiguration.setHostName(hostName);
    redisStandaloneConfiguration.setPort(port);

    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setMaxIdle(maxIdle);
    poolConfig.setMinIdle(minIdle);
    poolConfig.setMaxWaitMillis(maxWaitMillis);
    poolConfig.setMaxTotal(maxTotal);

    LettucePoolingClientConfiguration lettucePoolingClientConfiguration = LettucePoolingClientConfiguration.builder()
            .commandTimeout(Duration.ofSeconds(10))
            .shutdownTimeout(Duration.ZERO)
            .poolConfig(poolConfig)
            .build();

    LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory(redisStandaloneConfiguration, lettucePoolingClientConfiguration);
    lettuceConnectionFactory.setShareNativeConnection(false);

    return lettuceConnectionFactory;
}
 
Example #2
Source File: RedisConfig.java    From jeesupport with MIT License 6 votes vote down vote up
@Bean
public LettucePoolingClientConfiguration lettucePoolConfig( ClientOptions _co, ClientResources _cr ){
    GenericObjectPoolConfig gopc = new GenericObjectPoolConfig();

    gopc.setMaxIdle( CommonConfig.getInteger( "spring.redis.pool.max-idle", DEFAULT_MAX_IDLE ) );
    gopc.setMinIdle( CommonConfig.getInteger( "spring.redis.pool.min-idle", DEFAULT_MIN_IDLE ) );
    gopc.setMaxTotal( CommonConfig.getInteger( "spring.redis.pool.max-active", DEFAULT_MAX_TOTAL ) );
    gopc.setMaxWaitMillis( CommonConfig.getLong( "spring.redis.pool.max-wait", DEFAULT_MAX_WAIT_MILLIS ) );
    gopc.setEvictorShutdownTimeoutMillis( CommonConfig.getLong( "spring.redis.pool.timeout",
                                                                DEFAULT_EVICTOR_SHUTDOWN_TIMEOUT_MILLIS ) );

    return LettucePoolingClientConfiguration.builder()
            .poolConfig( gopc )
            .clientOptions( _co )
            .clientResources( _cr )
            .build();
}
 
Example #3
Source File: RedisConfiguration.java    From ad with Apache License 2.0 5 votes vote down vote up
@Bean
public LettuceConnectionFactory lettuceConnectionFactory() {
    LettucePoolingClientConfiguration configuration = LettucePoolingClientConfiguration.builder()
            .poolConfig(genericObjectPoolConfig())
            .commandTimeout(Duration.ofMillis(timeout))
            .build();
    LettuceConnectionFactory factory = new LettuceConnectionFactory(standaloneConfiguration(), configuration);
    factory.setShareNativeConnection(true);
    return factory;
}
 
Example #4
Source File: RedisAutoConfig.java    From unimall with Apache License 2.0 5 votes vote down vote up
/**** 缓存专用数据源 ****/
@Bean
public LettuceConnectionFactory defaultLettuceConnectionFactory(
        RedisStandaloneConfiguration defaultRedisConfig,GenericObjectPoolConfig defaultPoolConfig) {
    LettuceClientConfiguration clientConfig =
            LettucePoolingClientConfiguration.builder().commandTimeout(Duration.ofMillis(5000))
                    .poolConfig(defaultPoolConfig).build();
    return new LettuceConnectionFactory(defaultRedisConfig, clientConfig);
}
 
Example #5
Source File: RedisAutoConfig.java    From unimall with Apache License 2.0 5 votes vote down vote up
/**** 用户SESSION专用数据源 ****/
@Bean
public LettuceConnectionFactory userLettuceConnectionFactory(
        RedisStandaloneConfiguration userRedisConfig,GenericObjectPoolConfig userPoolConfig) {
    LettuceClientConfiguration clientConfig =
            LettucePoolingClientConfiguration.builder().commandTimeout(Duration.ofMillis(5000))
                    .poolConfig(userPoolConfig).build();
    return new LettuceConnectionFactory(userRedisConfig, clientConfig);
}
 
Example #6
Source File: RedisAutoConfig.java    From unimall with Apache License 2.0 5 votes vote down vote up
/**** 锁专用数据源 ****/
@Bean
public LettuceConnectionFactory lockLettuceConnectionFactory(
        RedisStandaloneConfiguration lockRedisConfig,GenericObjectPoolConfig lockPoolConfig) {
    LettuceClientConfiguration clientConfig =
            LettucePoolingClientConfiguration.builder().commandTimeout(Duration.ofMillis(5000))
                    .poolConfig(lockPoolConfig).build();
    return new LettuceConnectionFactory(lockRedisConfig, clientConfig);
}
 
Example #7
Source File: RedisConfig.java    From jeesupport with MIT License 5 votes vote down vote up
@Bean
public RedisConnectionFactory connectionFactory( RedisStandaloneConfiguration _rsc,
                                                 LettucePoolingClientConfiguration _lpcc ){
    int database = CommonConfig.getInteger( "spring.redis.database", 0 );

    LettuceConnectionFactory lcf = new LettuceConnectionFactory( _rsc, _lpcc );
    lcf.setShareNativeConnection( false );
    lcf.setDatabase( database );
    return lcf;
}
 
Example #8
Source File: RedisConfig.java    From spring-boot-redis-guava-caffeine-cache with Apache License 2.0 5 votes vote down vote up
@Bean
@Primary
public LettuceConnectionFactory factoryA(GenericObjectPoolConfig config, RedisStandaloneConfiguration redisConfigA) {
    LettuceClientConfiguration clientConfiguration = LettucePoolingClientConfiguration.builder()
            .poolConfig(config).commandTimeout(Duration.ofMillis(config.getMaxWaitMillis())).build();
    return new LettuceConnectionFactory(redisConfigA, clientConfiguration);
}
 
Example #9
Source File: RedisConnectionFactoryCloudConfigTestHelper.java    From spring-cloud-connectors with Apache License 2.0 5 votes vote down vote up
public static void assertPoolProperties(RedisConnectionFactory connector, int maxActive, int minIdle, long maxWait) {
	GenericObjectPoolConfig poolConfig = null;
	if (connector instanceof JedisConnectionFactory) {
		poolConfig = ((JedisConnectionFactory) connector).getPoolConfig();
	} else if (connector instanceof LettuceConnectionFactory) {
		LettuceClientConfiguration config = ((LettuceConnectionFactory) connector).getClientConfiguration();
		assertThat(config, instanceOf(LettucePoolingClientConfiguration.class));
		poolConfig = ((LettucePoolingClientConfiguration) config).getPoolConfig();
	}
	assertCommonsPoolProperties(poolConfig, maxActive, minIdle, maxWait);
}
 
Example #10
Source File: LettuceConnFactoryProvider.java    From sofa-dashboard-client with Apache License 2.0 4 votes vote down vote up
LettuceClientConfigurationBuilder createBuilder(Pool properties) {
    return LettucePoolingClientConfiguration.builder()
        .poolConfig(getPoolConfig(properties));
}
 
Example #11
Source File: RateLimiterPluginDataHandler.java    From soul with Apache License 2.0 4 votes vote down vote up
private LettuceClientConfiguration getLettuceClientConfiguration(final RateLimiterConfig rateLimiterConfig) {
    return LettucePoolingClientConfiguration.builder().poolConfig(getPoolConfig(rateLimiterConfig)).build();
}
 
Example #12
Source File: RedisConfig.java    From spring-boot-redis-guava-caffeine-cache with Apache License 2.0 4 votes vote down vote up
@Bean
public LettuceConnectionFactory factoryB(GenericObjectPoolConfig config, RedisStandaloneConfiguration redisConfigB) {
    LettuceClientConfiguration clientConfiguration = LettucePoolingClientConfiguration.builder()
            .poolConfig(config).commandTimeout(Duration.ofMillis(config.getMaxWaitMillis())).build();
    return new LettuceConnectionFactory(redisConfigB, clientConfiguration);
}