Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- await this.executionPolicy.ExecuteAsync(
- async () =>
- {
- using (var connection = this.PooledConnection)
- {
- var multiplexers = new List<RedLockMultiplexer> { new RedLockMultiplexer(connection.Value) };
- using (var redlockFactory = RedLockFactory.Create(multiplexers))
- {
- const string Resource = "the-thing-we-are-locking-on";
- var lockExpiry = TimeSpan.FromSeconds(20);
- using (var redLock = await redlockFactory.CreateLockAsync(Resource, lockExpiry))
- {
- if (redLock.IsAcquired)
- {
- return await connection.Value.GetDatabase()
- .HashGetAsync(hashKey, hashField, GetRedisCommandFlags(commandFlag))
- .ConfigureAwait(false);
- }
- return new RedisValue();
- }
- }
- }
- })
- .ConfigureAwait(false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement