Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cyejing/dsync

分布式锁 distributed synchronize lock
https://github.com/cyejing/dsync

Last synced: 8 days ago
JSON representation

分布式锁 distributed synchronize lock

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. 添加依赖
```xml

cn.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();
}
```