高性能分布式状态同步与原子操作数据库。通过锁队列、高性能异步二进制网络协议提供良好的多核支持。 可用于尖峰、同步、事件通知、并发控制等。支持Redis客户端。
https://github.com/snower/slock
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| package main;
import io.github.snower.jaslock.Client; import io.github.snower.jaslock.Event; import io.github.snower.jaslock.Lock; import io.github.snower.jaslock.ReplsetClient; import io.github.snower.jaslock.exceptions.SlockException;
import java.io.IOException; import java.nio.charset.StandardCharsets;
public class App { public static void main(String[] args) { ReplsetClient replsetClient = new ReplsetClient(new String[]{"172.27.214.150:5658"}); try { replsetClient.open(); Lock lock = replsetClient.newLock("test".getBytes(StandardCharsets.UTF_8), 5, 5); lock.acquire(); lock.release(); } catch (SlockException e) { e.printStackTrace(); } finally { replsetClient.close(); } } }
|
Client库
文章