/// <summary> /// Redis Set操作 /// </summary> /// <param name="key"></param> /// <returns></returns> public static List <string> HashGet(string key) { List <string> values = new List <string>(); using (var redisClient = basicRedisClientManager.GetClient()) { IHasNamed <IRedisSet> rr = redisClient.Sets; HashSet <string> HashSetString = rr[key].GetAll(); foreach (string str in HashSetString) { values.Add(str); } } return(values); }
static void Main1(string[] args) { string rs = ConfigurationManager.AppSettings["RedisServerIP"].ToString(); BasicRedisClientManager basicRedisClientManager = new BasicRedisClientManager(rs); using (var redisClient = basicRedisClientManager.GetClient()) { redisClient.AddItemToSet("蜀国", "刘备"); redisClient.AddItemToSet("蜀国", "关羽"); redisClient.AddItemToSet("蜀国", "张飞"); redisClient.GetAllKeys(); IHasNamed <IRedisSet> rr = redisClient.Sets; HashSet <string> HashSetString = rr["蜀国"].GetAll(); foreach (string str in HashSetString) { Console.WriteLine(str); } } }