zoukankan      html  css  js  c++  java
  • 一个练手的小项目(二)——Redis集群

    RedisConfig.java:

    package com.tsvv.config;
    
    import java.util.HashSet;
    import java.util.Set;
    
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.PropertySource;
    
    import redis.clients.jedis.HostAndPort;
    import redis.clients.jedis.JedisCluster;
    
    //标识配置类
    @Configuration
    @PropertySource("classpath:/properties/redis.properties")
    public class RedisConfig {
    
        @Value("${redis.clusterNodes}")
        private String nodes;
    
        @Bean
        public JedisCluster jedisCluster() {
            Set<HostAndPort> nodeSet=new HashSet<>();
            String[] arrayNodes=nodes.split(",");
            for (String node : arrayNodes) {
                String host=node.split(":")[0];
                int port=Integer.parseInt(node.split(":")[1]);
                nodeSet.add(new HostAndPort(host, port));
            }
            return new JedisCluster(nodeSet);
        }
        
    }

    redis.properties:

    #最小空闲数
    redis.minIdle=100
    #最大空闲数
    redis.maxIdle=300
    #最大连接数
    redis.maxTotal=1000
    #定义redis节点信息
    redis.clusterNodes=192.168.6.129:7000,192.168.6.129:7001,192.168.6.129:7002,192.168.6.129:7003,192.168.6.129:7004,192.168.6.129:7005
  • 相关阅读:
    二分图匹配初步
    动态规划初步
    一些排日程的经典方法
    petri网初步
    笔记:美国院士教你写论文
    Ubuntu18.04彻底删除MySQL数据库
    ubuntu18.04 安装 wps2019
    ubuntu18.04 阿里镜像源
    Ubuntu 18.04 使用标准Ubuntu 仓库进行自动化安装NVIDIA驱动
    linux maven环境变量配置
  • 原文地址:https://www.cnblogs.com/tsvv-plus/p/11911198.html
Copyright © 2011-2022 走看看