package com.gyee.frame.common.conf;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * 读取项目相关配置
 * 
 * @author gyee
 */

@Configuration
@ConfigurationProperties(prefix = "redis")
public class RedisConfig
{
    public static String redis_ss_ip;
    public static Integer redis_ss_port;
    public static String redis_ls_ip;
    public static Integer redis_ls_port;

    @Bean(name = "ss_redis")
    public static JedisPool redis_SS_Pool_Factory()  throws Exception{

        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxIdle(2000);
        jedisPoolConfig.setMaxWaitMillis(500);

        // 是否启用pool的jmx管理功能, 默认true
        jedisPoolConfig.setJmxEnabled(true);
        JedisPool jedisPool = new JedisPool(jedisPoolConfig, redis_ss_ip, redis_ss_port);
        return jedisPool;
    }

    @Bean(name = "ls_redis")
    public static JedisPool redis_LS_PoolFactory()  throws Exception{

        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxIdle(2000);
        jedisPoolConfig.setMaxWaitMillis(500);

        // 是否启用pool的jmx管理功能, 默认true
        jedisPoolConfig.setJmxEnabled(true);
        JedisPool jedisPool = new JedisPool(jedisPoolConfig, redis_ls_ip, redis_ls_port);
        return jedisPool;
    }

    public static String getRedis_ss_ip() {
        return redis_ss_ip;
    }

    public static void setRedis_ss_ip(String redis_ss_ip) {
        RedisConfig.redis_ss_ip = redis_ss_ip;
    }

    public static Integer getRedis_ss_port() {
        return redis_ss_port;
    }

    public static void setRedis_ss_port(Integer redis_ss_port) {
        RedisConfig.redis_ss_port = redis_ss_port;
    }

    public static String getRedis_ls_ip() {
        return redis_ls_ip;
    }

    public static void setRedis_ls_ip(String redis_ls_ip) {
        RedisConfig.redis_ls_ip = redis_ls_ip;
    }

    public static Integer getRedis_ls_port() {
        return redis_ls_port;
    }

    public static void setRedis_ls_port(Integer redis_ls_port) {
        RedisConfig.redis_ls_port = redis_ls_port;
    }
}
