Exemple #1
0
        public static async void Test(string key)
        {
            Dictionary <string, Data.TestData> keyValues = new Dictionary <string, Data.TestData>();

            for (int i = 0; i < 10; i++)
            {
                keyValues[i.ToString()] = new Data.TestData()
                {
                    name = "hello", age = i
                };
            }
            Stopwatch sw = new Stopwatch();

            sw.Start();
            for (int i = 0; i < 100000; i++)
            {
                try
                {
                    var result = await redis.HMSet(key, keyValues);

                    var obj = await redis.HGet <Data.TestData>(key, "5");

                    await redis.Del(key);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            sw.Stop();
            Console.WriteLine("Test Time:" + sw.Elapsed);
        }
Exemple #2
0
        public async Task HSetAndDel()
        {
            var setResult = await redis.HSet("hello", "18", new TestData()
            {
                name = "hello", age = 18
            });

            Assert.AreEqual(setResult, 1);

            var getResult = await redis.HGet <TestData>("hello", "18");

            Assert.AreEqual(getResult.name, "hello");

            var getResult2 = (TestData)await redis.HGet(typeof(TestData), "hello", "18");

            Assert.AreEqual(getResult2.name, "hello");

            var delResult = await redis.HDel("hello", "18");

            Assert.AreEqual(delResult, 1);
        }