Esempio n. 1
0
        static void Main(string[] args)
        {
            ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("127.0.0.0:6379,allowAdmin=true");
            var redLockFactory = new RedLockFactory(connection);

            using (var redLock = redLockFactory.GetLock("lock", TimeSpan.FromMinutes(10), 2, TimeSpan.FromSeconds(2)))
            {
                Console.WriteLine("[A] Try to get lock");
                if (redLock.IsAcquired)
                {
                    Console.WriteLine("[A] Geted lock");
                    Thread.Sleep(10000);
                }
                else
                {
                    Console.WriteLine("[A] UnAcquired");
                }
            }
            Console.WriteLine("[A] End");
            Console.ReadLine();
        }