RedLock in Java
Implementation based on Redlock-rb
This Java library implements the Redis-based distributed lock manager algorithm described in this blog post.
Include the dependency into your project:
<dependency>
<groupId>io.github.s-sathish</groupId>
<artifactId>redlock-java</artifactId>
<version>1.0.4</version>
</dependency>
To create a lock manager:
RedLock redLock = new RedLock();
To acquire a lock:
LockResult lockResult = redLock.lock("redlock");
To release a lock:
redLock.release("redlock", lockResult.getValue());