Is Redisson's getLock()
method good for a distributed use case, and how does it compare to getRedLock()
?
Redisson (3.11.x) has several methods to instantiate locks:
- RedissonClient.getLock()
- RedissonClient.getRedLock()
- others like
getReadWriteLock()
,getFairLock()
, etc.
What algorithm does getLock()
use, and is it safe for distributed usage? The documentation says:
Implements a non-fair locking so doesn't guarantees an acquire order by threads.
I am looking to compare getLock()
to getRedLock()
, which appears to use Redlock and is documented at the top-level of Redis' distlock
page: https://redis.io/topics/distlock:
This page is an attempt to provide a more canonical algorithm to implement distributed locks with Redis. We propose an algorithm, called Redlock, which implements a DLM which we believe to be safer than the vanilla single instance approach.