static async Task Main(string[] args) { // setup redis lock manager ConnectionMultiplexer connectionMultiplexer = await ConnectionMultiplexer.ConnectAsync("localhost:6379"); ILockManager manager = new RedisLockManager(connectionMultiplexer, "MyServer"); // generate our locks List <string> locks = Enumerable.Repeat(0, 2048).Select(i => $"tandem://{Guid.NewGuid().ToString()}").ToList(); List <ILockHandle> lockHandles = new List <ILockHandle>(); // create stopwatch Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // setup foreach (string l in locks) { lockHandles.Add(await manager.LockAsync(l, TimeSpan.FromSeconds(5)).ConfigureAwait(false)); } // time stopwatch.Stop(); Console.WriteLine($"Added 1024 locks in {stopwatch.Elapsed.TotalMilliseconds}ms"); await Task.Delay(Timeout.InfiniteTimeSpan); }
static async Task MainAsync(string[] args) { ConnectionMultiplexer connectionMultiplexer = await ConnectionMultiplexer.ConnectAsync("localhost:6379"); ILockManager manager = new RedisLockManager(connectionMultiplexer, "MyServer"); A1(manager); A2(manager); await ProceedSemaphore.WaitAsync(); Console.WriteLine("Done!"); await Task.Delay(Timeout.InfiniteTimeSpan); }