https://github.com/xinlc/lock4j
Distributed lock implementation using Redis and Zookeeper.(基于 Redis 和 Zookeeper 分布式锁实现)
https://github.com/xinlc/lock4j
distributed lock redis-lock
Last synced: 18 days ago
JSON representation
Distributed lock implementation using Redis and Zookeeper.(基于 Redis 和 Zookeeper 分布式锁实现)
- Host: GitHub
- URL: https://github.com/xinlc/lock4j
- Owner: xinlc
- License: apache-2.0
- Created: 2020-09-27T05:42:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-02T06:54:48.000Z (about 4 years ago)
- Last Synced: 2025-04-04T01:32:08.037Z (2 months ago)
- Topics: distributed, lock, redis-lock
- Language: Java
- Homepage:
- Size: 94.7 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lock4j
Distributed lock implementation using Redis and Zookeeper.(基于 Redis 和 Zookeeper 分布式锁实现)
## Quick Start
Below is a simple demo. Talk is cheap. Show me the code.
### 1. Add Dependency
If your're using Maven, just add the following dependency in `pom.xml`.
```xml
com.github.xinlc
lock4j-spring-boot-starter
1.0.1```
If not, you can download JAR in [Maven Center Repository](https://mvnrepository.com/artifact/com.github.xinlc/lock4j-core).
### 2. Define Controller
```java
@DistributedLockable(
prefix = "hello",
argNames = {"name"},
expireTime = 10,
unit = TimeUnit.SECONDS,
onFailure = HelloLockException.class
)
@GetMapping
public void hello(@RequestParam("name") String name) {
log.info("hello {}", name);
}
```> More [examples](https://github.com/xinlc/lock4j/tree/master/samples).
## TODO
- [ ] Zookeeper implementation.