此软件包为使用 Redis 的分布式锁提供了一个 Swift 实现。它旨在与 distributed-lock-swift 和 RediStack 一起使用。
import DistributedLockRedis
let lock = RedisLock(client: redisClient)
try await lock.withLock("my-resource") {
// operations that should be protected by the lock
}
它还为锁等待被获取的时间提供了日志记录和追踪支持。