예제 #1
0
        public async Task HMSetAndDel()
        {
            Dictionary <string, TestData> keyValues = new Dictionary <string, TestData>();

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

            var setResult = await redis.HMSet("hello", keyValues);

            Assert.AreEqual(setResult, true);

            var getResult = await redis.HGetAll <TestData>("hello");

            Assert.AreEqual(getResult.Count, 10);

            var getResult2 = (await redis.HGetAll(typeof(TestData), "hello")).ConvertAll(c => (TestData)c);

            Assert.AreEqual(getResult2.Count, 10);

            var delResult = await redis.Del("hello");

            Assert.AreEqual(delResult, 1);
        }
예제 #2
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);
        }
예제 #3
0
 public void Remove(string key)
 {
     _redis.Del(key);
 }