Skip to content

分布式锁 spring-boot-nebula-distribute-lock ​

基于 Redisson 的声明式分布式锁。

引入依赖 ​

xml
<dependency>
    <groupId>io.github.weihubeats</groupId>
    <artifactId>spring-boot-nebula-distribute-lock</artifactId>
    <version>3.0.6</version>
</dependency>

前置条件 ​

需自行配置 RedissonClient Bean(参考示例中的 RedissonConfig)。

使用方式 ​

java
@NebulaDistributedLock(lockNamePre = "order:updateOrder:", lockNamePost = "#dto.orderId")
public void updateOrder(OrderDTO dto) { ... }
属性默认值说明
lockNamePre""锁名前缀
lockNamePost""锁名后缀,支持 SpEL
tryLockfalse是否尝试加锁
tryWaitTime30尝试等待时间
outTime20锁超时自动释放时间
timeUnitSECONDS时间单位
fairLockfalse是否公平锁

示例模块:spring-boot-nebula-distribute-lock-sample。

Released under the Apache 2.0 License.