|
20 | 20 | @EnableConfigurationProperties(RedisProperties.class)
|
21 | 21 | public class RediSearchAutoConfiguration {
|
22 | 22 |
|
23 |
| - @Bean |
24 |
| - RedisURI redisURI(RedisProperties properties) { |
25 |
| - RedisURI redisURI = RedisURI.create(properties.getHost(), properties.getPort()); |
26 |
| - if (properties.getPassword() != null) { |
27 |
| - redisURI.setPassword(properties.getPassword()); |
28 |
| - } |
29 |
| - Duration timeout = properties.getTimeout(); |
30 |
| - if (timeout != null) { |
31 |
| - redisURI.setTimeout(timeout); |
32 |
| - } |
33 |
| - return redisURI; |
34 |
| - } |
| 23 | + @Bean |
| 24 | + RedisURI redisURI(RedisProperties properties) { |
| 25 | + RedisURI redisURI = RedisURI.create(properties.getHost(), properties.getPort()); |
| 26 | + if (properties.getPassword() != null) { |
| 27 | + redisURI.setPassword(properties.getPassword().toCharArray()); |
| 28 | + } |
| 29 | + Duration timeout = properties.getTimeout(); |
| 30 | + if (timeout != null) { |
| 31 | + redisURI.setTimeout(timeout); |
| 32 | + } |
| 33 | + return redisURI; |
| 34 | + } |
35 | 35 |
|
36 |
| - @Bean(destroyMethod = "shutdown") |
37 |
| - ClientResources clientResources() { |
38 |
| - return DefaultClientResources.create(); |
39 |
| - } |
| 36 | + @Bean(destroyMethod = "shutdown") |
| 37 | + ClientResources clientResources() { |
| 38 | + return DefaultClientResources.create(); |
| 39 | + } |
40 | 40 |
|
41 |
| - @Bean(destroyMethod = "shutdown") |
42 |
| - RediSearchClient client(RedisURI redisURI, ClientResources clientResources) { |
43 |
| - return RediSearchClient.create(clientResources, redisURI); |
44 |
| - } |
| 41 | + @Bean(destroyMethod = "shutdown") |
| 42 | + RediSearchClient client(RedisURI redisURI, ClientResources clientResources) { |
| 43 | + return RediSearchClient.create(clientResources, redisURI); |
| 44 | + } |
45 | 45 |
|
46 |
| - @Bean(name = "rediSearchConnection", destroyMethod = "close") |
47 |
| - StatefulRediSearchConnection<String, String> connection(RediSearchClient rediSearchClient) { |
48 |
| - return rediSearchClient.connect(); |
49 |
| - } |
| 46 | + @Bean(name = "rediSearchConnection", destroyMethod = "close") |
| 47 | + StatefulRediSearchConnection<String, String> connection(RediSearchClient rediSearchClient) { |
| 48 | + return rediSearchClient.connect(); |
| 49 | + } |
50 | 50 |
|
51 |
| - @Bean(name = "rediSearchConnectionPoolConfig") |
52 |
| - GenericObjectPoolConfig<StatefulRediSearchConnection<String, String>> poolConfig(RedisProperties redisProperties) { |
53 |
| - return configure(redisProperties, new GenericObjectPoolConfig<>()); |
54 |
| - } |
| 51 | + @Bean(name = "rediSearchConnectionPoolConfig") |
| 52 | + GenericObjectPoolConfig<StatefulRediSearchConnection<String, String>> poolConfig(RedisProperties redisProperties) { |
| 53 | + return configure(redisProperties, new GenericObjectPoolConfig<>()); |
| 54 | + } |
55 | 55 |
|
56 |
| - public <K, V> GenericObjectPoolConfig<StatefulRediSearchConnection<K, V>> configure(RedisProperties redisProperties, GenericObjectPoolConfig<StatefulRediSearchConnection<K, V>> config) { |
57 |
| - config.setJmxEnabled(false); |
58 |
| - Pool poolProps = redisProperties.getLettuce().getPool(); |
59 |
| - if (poolProps != null) { |
60 |
| - config.setMaxTotal(poolProps.getMaxActive()); |
61 |
| - config.setMaxIdle(poolProps.getMaxIdle()); |
62 |
| - config.setMinIdle(poolProps.getMinIdle()); |
63 |
| - if (poolProps.getMaxWait() != null) { |
64 |
| - config.setMaxWaitMillis(poolProps.getMaxWait().toMillis()); |
65 |
| - } |
66 |
| - } |
67 |
| - return config; |
68 |
| - } |
| 56 | + public <K, V> GenericObjectPoolConfig<StatefulRediSearchConnection<K, V>> configure(RedisProperties redisProperties, |
| 57 | + GenericObjectPoolConfig<StatefulRediSearchConnection<K, V>> config) { |
| 58 | + config.setJmxEnabled(false); |
| 59 | + Pool poolProps = redisProperties.getLettuce().getPool(); |
| 60 | + if (poolProps != null) { |
| 61 | + config.setMaxTotal(poolProps.getMaxActive()); |
| 62 | + config.setMaxIdle(poolProps.getMaxIdle()); |
| 63 | + config.setMinIdle(poolProps.getMinIdle()); |
| 64 | + if (poolProps.getMaxWait() != null) { |
| 65 | + config.setMaxWaitMillis(poolProps.getMaxWait().toMillis()); |
| 66 | + } |
| 67 | + } |
| 68 | + return config; |
| 69 | + } |
69 | 70 |
|
70 |
| - @Bean(name = "rediSearchConnectionPool", destroyMethod = "close") |
71 |
| - GenericObjectPool<StatefulRediSearchConnection<String, String>> pool(GenericObjectPoolConfig<StatefulRediSearchConnection<String, String>> config, RediSearchClient client) { |
72 |
| - return ConnectionPoolSupport.createGenericObjectPool(client::connect, config); |
73 |
| - } |
| 71 | + @Bean(name = "rediSearchConnectionPool", destroyMethod = "close") |
| 72 | + GenericObjectPool<StatefulRediSearchConnection<String, String>> pool( |
| 73 | + GenericObjectPoolConfig<StatefulRediSearchConnection<String, String>> config, RediSearchClient client) { |
| 74 | + return ConnectionPoolSupport.createGenericObjectPool(client::connect, config); |
| 75 | + } |
74 | 76 |
|
75 | 77 | }
|
0 commit comments