package com.shkj.wms.config;

import org.apache.commons.lang3.StringUtils;
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * redission配置
 *
 * @author lch
 * @date 2023/02/23 09:31:03
 */
@Configuration
public class RedissonConfig {

    /**
     * 本地没有password的时候 设置密码为null 不然源码默认设置为 ""
     * */
    @Bean
    public RedissonAutoConfigurationCustomizer redissonAutoConfigurationCustomizer() {
        return configuration -> {
            if (StringUtils.isEmpty(configuration.useSingleServer().getPassword())) {
                configuration.useSingleServer().setPassword(null);
            }
        };
    }
}
