您的位置:首页 > 数据库 > Redis

Redis

2015-08-24 00:35 387 查看
Redis的数据类型

var client = new RedisClient("127.0.0.1", 6379);
//client.Set<string>("name", "zhangsan");
//string name= client.Get<string>("name");
// client.Set<int>("age", 13);
// Console.WriteLine(name);

//  client.SetEntryInHash("userId", "username1", "lisi");
//  client.SetEntryInHash("userId", "age", "23");

//// List<string>list= client.GetHashKeys("userId");
//  List<string> list = client.GetHashValues("userId");
// foreach (string key in list)
// {
//     Console.WriteLine(key);
// }

//client.EnqueueItemOnList("userName", "wangwu");//入队(先进先出.)
//client.EnqueueItemOnList("userName", "qianqi");
//int count=client.GetListCount("userName");
//for (var i = 0; i <count; i++)
//{
//   Console.WriteLine(client.DequeueItemFromList("userName"));//出队.
//}

//client.PushItemToList("name3", "maliu");//入栈
//client.PushItemToList("name3", "maliu333");
//int count = client.GetListCount("name3");
//for (var i = 0; i < count; i++)
//{
//    Console.WriteLine(client.PopItemFromList("name3"));//出栈
//}

client.AddItemToSet("a3", "ddd");
client.AddItemToSet("a3", "ccc");
client.AddItemToSet("a3", "tttt");
client.AddItemToSet("a3", "sssh");
client.AddItemToSet("a3", "hhhh");
System.Collections.Generic.HashSet<string> hashset = client.GetAllItemsFromSet("a3");
foreach (string str in hashset)
{
Console.WriteLine(str);
}

Console.ReadKey();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: