1.nuget 安装动态库:ServiceStack.Redis,会默认安装如下几个dll:
2.简单使用,前提是Redis服务器已经启动,我这里是在本地测试,redis默认端口是6379,关于windows如何安装redis请查看上一篇博文。
事例中简单列举了Redis可以存储字符串、整型、对象。
- var redisClient = new RedisClient("127.0.0.1",6379);
-
- redisClient.Set<string>("name", "henry");
- redisClient.Set("age", 34);
-
- var perple = new Perple
- {
- Name = "Jack",
- Grade = "95"
- };
- redisClient.Set("object", perple);
-
- var var1 = redisClient.Get("name");//取到的是byte数组
- var var11 = redisClient.Get<string>("name");
- var var2 = redisClient.Get("age");
- var var22 = redisClient.Get<int>("age");
- var var3 = redisClient.Get("object");
- var var33 = redisClient.Get<Perple>("object");
信息加载中,请等待
微信客服(速回)
微信客服(慢回)