package com.sqx.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * redisson配置
 *
 * @auther: codingliang
 * @date: 2023-10-19 13:20
 * @description: redisson配置
 */
@Configuration
public class RedissonConfig {

    @Bean
    public RedissonClient redissonClient(@Value("${spring.redis.host}") String url, @Value("${spring.redis.password}") String password, @Value("${spring.redis.port}") String port) {
        Config config = new Config();
        config.useSingleServer().setUsername("default").setPassword(password).setAddress("redis://" + url + ":" + port);
        return Redisson.create(config);
    }
}
