|
@@ -0,0 +1,45 @@
|
|
|
+package examples.dataloader;
|
|
|
+
|
|
|
+import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
|
+import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
|
|
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
|
|
+import redis.clients.jedis.JedisPoolConfig;
|
|
|
+import org.springframework.data.redis.connection.jedis.JedisClientConfiguration;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+
|
|
|
+
|
|
|
+public class redisBuilderMyself {
|
|
|
+
|
|
|
+
|
|
|
+ public static JedisConnectionFactory redisConnectionFactory() {
|
|
|
+
|
|
|
+ RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(
|
|
|
+ "r-bp1pi8wyv6lzvgjy5z.redis.rds.aliyuncs.com", 6379);
|
|
|
+ config.setPassword("Wqsd@2019");
|
|
|
+
|
|
|
+ JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
|
|
+
|
|
|
+ jedisPoolConfig.setMaxTotal(30);
|
|
|
+
|
|
|
+ jedisPoolConfig.setMaxIdle(20);
|
|
|
+
|
|
|
+ jedisPoolConfig.setTestOnBorrow(false);
|
|
|
+ jedisPoolConfig.setTestOnReturn(false);
|
|
|
+
|
|
|
+ JedisClientConfiguration jedisClientConfiguration = JedisClientConfiguration.builder().usePooling().poolConfig(
|
|
|
+ jedisPoolConfig).build();
|
|
|
+
|
|
|
+ return new JedisConnectionFactory(config, jedisClientConfiguration);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static RedisTemplate<String, String> redisTemplate(RedisConnectionFactory connectionFactory) {
|
|
|
+ RedisTemplate<String, String> template = new RedisTemplate<>();
|
|
|
+ template.setConnectionFactory(connectionFactory);
|
|
|
+ return template;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|