OpenrelikWorkerCommon.MountUtils.RedisLock (openrelik_worker_common v0.1.0)

Copy Markdown View Source

Distributed Redis lock for NBD device coordination across containers/nodes, matching Python redis.lock.Lock (name, timeout, token, acquire/1, release/1).

Summary

Functions

Attempts to acquire the Redis lock non-blockingly (SET name token NX EX timeout).

Creates a new RedisLock struct.

Releases the Redis lock if still owned by token.

Types

t()

@type t() :: %OpenrelikWorkerCommon.MountUtils.RedisLock{
  client: term(),
  name: String.t(),
  timeout: pos_integer(),
  token: String.t()
}

Functions

acquire(redis_lock)

@spec acquire(t()) :: boolean()

Attempts to acquire the Redis lock non-blockingly (SET name token NX EX timeout).

new(client, name, timeout)

@spec new(term(), String.t(), pos_integer()) :: t()

Creates a new RedisLock struct.

release(redis_lock)

@spec release(t()) :: :ok

Releases the Redis lock if still owned by token.