Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyejing/dsync
分布式锁 distributed synchronize lock
https://github.com/cyejing/dsync
Last synced: 8 days ago
JSON representation
分布式锁 distributed synchronize lock
- Host: GitHub
- URL: https://github.com/cyejing/dsync
- Owner: cyejing
- Created: 2018-11-13T06:04:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-17T02:02:04.000Z (over 2 years ago)
- Last Synced: 2023-12-21T06:56:32.832Z (11 months ago)
- Language: Java
- Homepage:
- Size: 107 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# Distributed Synchronize 分布式同步组件
1. 分布式锁.
2. 基于Netty长连接实现.
3. 自定义协议,内置等待队列,性能远超redis锁.
4. 服务下线立刻感知,无需等待超时.
5. 支持优雅关闭.
6. 规避Redis分布式锁缺陷: http://zhangtielei.com/posts/blog-redlock-reasoning.html , http://zhangtielei.com/posts/blog-redlock-reasoning-part2.html### 启动服务端
```
java -jar -server dsync-dominate-xxx.jar
```
启动jar可以在maven下载,或者下载源码 ``mvn package`` 获得.
### 分布式锁 DLock
1. 添加依赖
```xmlcn.cyejing
dsync-toolkit```
2. 使用方法
```java
Config config = Config.config().host("localhost").port(4843); //配置服务端地址
DSync dSync = DSync.create(config);
DLock lock = dSync.getLock();try {
lock.lock("adder");
//Do Something
} finally {
lock.unlock();
}
```