Redis教程

redission分布式锁配置

本文主要是介绍redission分布式锁配置,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

具体的详解参考:

https://xie.infoq.cn/article/d8e897f768eb1a358a0fd6300

SpringBoot配置类:

@Configuration
public class RedissonConfig {

    @Resource
    private RedissonConfigProperites redissonConfigProperites;

    @Bean(destroyMethod="shutdown")
    RedissonClient redisson() {
        Config config = new Config();
        config.useSingleServer()
                .setAddress(redissonConfigProperites.getAddress())
                .setPassword(redissonConfigProperites.getPassword())
                .setDatabase(redissonConfigProperites.getDatabase());
        return Redisson.create(config);
    }

}
@Data
@Component
@ConfigurationProperties(prefix = "redisson")
public class RedissonConfigProperites {

    private String address;
    private String password;
    private int database;


}

 nacos配置:

redisson:
  address: redis://127.0.0.1:6379
  password: 123456
  database: 2

 

这篇关于redission分布式锁配置的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!