事情原因 我手上主redis 内存不大 ,不想迁移了,重新配置一台redis做额外计算使用,所以打算修改服务增加第二个redis连接配置 ,把新增需求放在第二个redis上计算,废话就不多说,上图和代码。
1.修改远程的配置文件增加第二个redis连接配置

多说一句 连接池不要太多连接 会造成大量碎片,健康度直线下降
2.服务增加Redis配置类
package cn.turing.firecontrol.device.config;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import redis.clients.jedis.JedisPoolConfig;
@Configuration
public class RedisConfig {
// 第一个Redis配置(原Redis)
@Value("${spring.redis.host}")
private String primaryHost;
@Value("${spring.redis.port}")
private int primaryPort;
@Value("${spring.redis.password}")
private String primaryPassword;
@Value("${spring.redis.database}")
private int primaryDatabase;
@Value("${spring.redis.t

最低0.47元/天 解锁文章
1971

被折叠的 条评论
为什么被折叠?



