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

The following examples show how to use org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration. These examples are extracted from open source projects. 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 Project: SpringMVC-Project   Source File: RedisConfig.java    License: MIT License 7 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 Project: jeesupport   Source File: RedisConfig.java    License: 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 Project: ad   Source File: RedisConfiguration.java    License: 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 Project: unimall   Source File: RedisAutoConfig.java    License: 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 Project: unimall   Source File: RedisAutoConfig.java    License: 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 Project: unimall   Source File: RedisAutoConfig.java    License: 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 Project: jeesupport   Source File: RedisConfig.java    License: 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
@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
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
LettuceClientConfigurationBuilder createBuilder(Pool properties) {
    return LettucePoolingClientConfiguration.builder()
        .poolConfig(getPoolConfig(properties));
}
 
Example 11
Source Project: soul   Source File: RateLimiterPluginDataHandler.java    License: 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
@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);
}