https://github.com/yingzhuo/redisson-redlock-spring-boot-starter
Redis RedLock for SpringBoot.
https://github.com/yingzhuo/redisson-redlock-spring-boot-starter
redis redisson redisson-lock spring-boot
Last synced: about 2 months ago
JSON representation
Redis RedLock for SpringBoot.
- Host: GitHub
- URL: https://github.com/yingzhuo/redisson-redlock-spring-boot-starter
- Owner: yingzhuo
- License: apache-2.0
- Created: 2024-12-04T03:02:36.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-03-30T10:40:35.000Z (about 2 months ago)
- Last Synced: 2025-03-30T11:27:45.127Z (about 2 months ago)
- Topics: redis, redisson, redisson-lock, spring-boot
- Language: Java
- Homepage:
- Size: 141 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Security: SECURITY.md
Awesome Lists containing this project
README
# redisson-redlock-spring-boot-starter
[](https://search.maven.org/search?q=g:%22com.github.yingzhuo%22%20AND%20a:%22redisson-redlock-spring-boot-starter%22)
### 依赖 (maven):
```xml
com.github.yingzhuo
redisson-redlock-spring-boot-starter
3.45.1```
### 依赖 (gradle):
```groovy
implementation 'com.github.yingzhuo:redisson-redlock-spring-boot-starter:3.45.1'
```### 使用
```yaml
# application.yaml
red-lock:
enabled: true
allow-downgrade-to-non-multi-lock: true
register-aop-aspect-advice: true
nodes:
- address: "127.0.0.1:6379"
username: "root"
password: "root"
- address: "127.0.0.1:6380"
username: "root"
password: "root"
- address: "127.0.0.1:6381"
username: "root"
password: "root"
``````java
@SpringBootTest(classes = TestApplication.class)
public class RedissonRedLockFactoryTest {@Autowired
private RedissonRedLockFactory lockFactory;@Test
public void test() {
var lock = lockFactory.createMultiLock("my-lock");lock.lock(10, TimeUnit.SECONDS);
try {
System.out.println("do some work.");
System.out.println("do some work.");
} finally {
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
}
```### 许可证
* [Apache-2.0](./LICENSE.txt)