Skip to content

Add distributed lock support #638

@imperugo

Description

@imperugo

Summary

Add distributed locking via SE.Redis's built-in `LockTake`/`LockRelease`/`LockExtend`.

Proposed API

```csharp
Task LockTakeAsync(string key, string value, TimeSpan expiry, CommandFlags flag = CommandFlags.None);
Task LockReleaseAsync(string key, string value, CommandFlags flag = CommandFlags.None);
Task LockExtendAsync(string key, string value, TimeSpan expiry, CommandFlags flag = CommandFlags.None);
Task<string?> LockQueryAsync(string key, CommandFlags flag = CommandFlags.None);
```

Considerations

  • Document the lock value pattern (use unique identifier per holder)
  • Consider an `IAsyncDisposable` wrapper: `using var lock = await redis.AcquireLockAsync("key", TimeSpan.FromSeconds(30))`
  • Consider retry logic with configurable backoff

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions