package org.springblade.common.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springblade.common.filter.PreviewFilter;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * redis锁
 *
 * @author Chill
 */
@Configuration
@SuppressWarnings("all")
public class RedissonConfiguration {
	@Value("${blade.lock.address}")
	private String address;
	@Value("${blade.lock.password:}")
	private String password;
	@Bean
	public RedissonClient redissonClient() {
		Config config = new Config();
		config.useSingleServer().setAddress(address);
		if(StringUtil.isNotBlank(password)){
			config.useSingleServer().setPassword(password);
		}
		return Redisson.create(config);
	}

}
