# redis-lock-spring-boot-starter
**Repository Path**: HsinDumas/redis-lock-spring-boot-starter
## Basic Information
- **Project Name**: redis-lock-spring-boot-starter
- **Description**: Spring Boot 最简单适配的redis分布式锁实现
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 4
- **Forks**: 1
- **Created**: 2020-12-30
- **Last Updated**: 2025-02-12
## Categories & Tags
**Categories**: spring-boot-ext
**Tags**: None
## README
## 简介
[](https://www.apache.org/licenses/LICENSE-2.0.html)
[](https://maven-badges.herokuapp.com/maven-central/com.github.hsindumas/redis-lock-spring-boot-starter)
[](https://github.com/HsinDumas/redis-lock-spring-boot-starter/releases)
[](https://docs.oracle.com/javase/8/docs/index.html)
[](https://docs.spring.io/spring-boot/docs/2.7.1/reference/htmlsingle/)
[](https://juejin.im/user/3562073404738584/posts)
本插件是以AOP的形式加上redisson的封装实现。
**`redis-lock-spring-boot-starter`将`redisson`与`spring-boot`框架整合,目的是为了给`spring-boot`开发者提供`最简单`
的基于redis的分布式锁**。
🚀项目持续优化迭代,欢迎大家提ISSUE和PR!麻烦大家能给一颗star✨,您的star是我持续更新的动力!
## 功能特性
- [x] 支持SPEL语法
- [x] 可重入锁
- [x] 公平锁
- [x] 联锁
- [x] 红锁
- [x] 读锁
- [x] 写锁
## 快速使用
### pom依赖
```xml
com.github.hsindumas
redis-lock-spring-boot-starter
1.2.6
```
### gradle依赖
```groovy
// https://mvnrepository.com/artifact/com.github.hsindumas/redis-lock-spring-boot-starter
compile group: 'com.github.hsindumas', name: 'redis-lock-spring-boot-starter', version: '1.2.6'
```
### 配置redis
按照redisson锁支持的方式,通过`spring.redis.redisson`或者`spring.redis`配置
### 使用
在需要加锁的方法上添加@Lock注释,设置好key,作为redis的key
```java
@Lock(keys = "test")
@Lock(keys = "#param", keyConstant = ":test")
```
`yml`配置方式: 可以修改全局的锁超时时间(默认30000毫秒)和等待时间(默认10000毫秒)
```yaml
lock:
lockTime:
waitTime:
```
## 反馈建议
如有任何问题,欢迎提issue。
## 鸣谢
- 感谢 JetBrains 提供的免费开源 License:
