架构图
功能介绍
原有的「RedisDistributedLock」类标记为过时,新增「RedissonDistributedLock」实现类,并优化了「DistributedLock」的抽象接口支持更多功能(屏蔽底层实现)
使用例子如下:
@Autowired
private DistributedLock locker;
Object lock = null;
try {
lock = locker.lock("test");
} finally {
locker.unlock(lock);
}
抽象了基本的锁功能满足绝大部分的需求,如果需要高级的锁功能,请自行扩展或直接使用原生api(不建议)
可重入
非公平
锁公平
锁redisson与lettuce一样也是基于Netty实现采用非阻塞IO性能高,并且功能更加强大
可通过以下三种方式操作redis
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private RedisRepository redisRepository;
@Autowired
private RedissonClient redisson;
「RedisTemplate」 Spring-Data-Redis的API 「RedisRepository」 在redisTemplate的基础上加了一层封装进行简化 「RedissonClient」 Redisson的API
Nacos 1.2 以上的版本,如果开启权限认证功能之后,服务注册和发现都需要配置username和password
配置方式如下所示:
##### nacos(注册中心和配置中心)地址
spring.cloud.nacos.server-addr=127.0.0.1:8848
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos
Gitee地址:
https://gitee.com/zlt2000/microservices-platform
Github地址:
https://github.com/zlt2000/microservices-platform
https://www.kancloud.cn/zlt2000/microservices-platform/919417
https://www.kancloud.cn/zlt2000/microservices-platform/936235