/// <summary>
        /// Redis Hash
        /// </summary>
        public static void Redis_Hash()
        {
            RedisClient client = new RedisClient("127.0.0.1", 6379);
            //清空数据库缓存,慎用
            client.FlushAll();
            #region Hash
            client.SetEntryInHash("Hash", "Name", "lily");
            client.SetEntryInHash("Hash", "Age", "18");
            client.SetEntryInHash("Hash", "Sex", "");
            client.SetEntryInHash("Hash", "Address", "初中高中英语课本");

            //获取指定hash表中key的集合
            List<string> HaskKey = client.GetHashKeys("Hash");
            //然后便利当前key
            foreach (string key in HaskKey)
            {
                Console.WriteLine("Hash--Key:{0}", key);
            }
            //获取指定hash表中value的集合
            List<string> HaskValue = client.GetHashValues("Hash");
            //便利当前value
            foreach (string value in HaskValue)
            {
                Console.WriteLine("Hash--Value:{0}", value);
            }

            //获取所有的key。
            List<string> AllKey = client.GetAllKeys(); //获取所有的key。
            foreach (string Key in AllKey)
            {
                Console.WriteLine("AllKey--Key:{0}", Key);
            }
            #endregion
        }

 

posted on 2018-02-05 10:49  高兴happy  阅读(1056)  评论(0编辑  收藏  举报