package com.ywt.mg.configs;

import com.ywt.mg.core.redis.ShardedJedisPoolFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import redis.clients.jedis.ShardedJedisPool;

@Component
public class AppConfigurer {

    @Value("${redis.address}")
    private String redisAddress;

    @Bean(name = "jedisPool")
    public ShardedJedisPool getJedisPool() throws Exception {
        ShardedJedisPoolFactory shardedJedisPoolFactory = new ShardedJedisPoolFactory();
        shardedJedisPoolFactory.setHostAndPorts(redisAddress);
        return shardedJedisPoolFactory.getObject();
    }
}