Redlock 是一个基于 Redis 的分布式锁实现,下载量超过 4000 万次。
RedisClient 客户端实例兼容。begin
block_result = lock_manager.lock!("resource_key", 2000) do
# critical code
end
rescue Redlock::LockError
# error handling
end要延长锁的使用寿命:
begin
lock_info = lock_manager.lock("resource_key", 2000)
while lock_info
# Critical code
# Time up and more work to do? Extend the lock.
lock_info = lock_manager.lock("resource key", 3000, extend: lock_info)
end
rescue Redlock::LockError
# error handling
end暂无开放 Issues,或尚未同步最近议题。