Exemplo n.º 1
0
        public static void Main()
        {
            var client             = new AsyncRedisClient();
            var connectionSettings = new ConnectionSettings("127.0.0.1", 6379);

            FailIfException(async() =>
            {
                Console.WriteLine($"Trying to connect to {connectionSettings.Address}:{connectionSettings.Port}...");
                await client.Connect(connectionSettings);
                Pass();
            }).GetAwaiter().GetResult();

            FailIfException(async() =>
            {
                Console.WriteLine("Trying simple write...");
                await client.Set(Key, Value);
                Pass();
            }).GetAwaiter().GetResult();

            FailIfException(async() =>
            {
                Console.WriteLine("Trying simple read...");
                var result = await client.Get(Key);
                if (result == Value)
                {
                    Pass();
                }
                else
                {
                    Fail("Read incorrect value from the server");
                }
            }).GetAwaiter().GetResult();

            FailIfException(async() =>
            {
                Console.WriteLine("Trying DbSize...");
                var result = await client.DbSize();

                if (result == 1)
                {
                    Pass();
                }
                else
                {
                    Fail("Read incorrect db size from the server");
                }
            }).GetAwaiter().GetResult();

            FailIfException(async() =>
            {
                Console.WriteLine("Trying delete...");
                await client.Del(Key);
                Pass();
            }).GetAwaiter().GetResult();
        }