Exemple #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);
        }