基于.Net Core的Redis:基本数据类型及其应用场景与命令行操作

参考自:https://blog.csdn.net/only_yu_yy/article/details/78873735

 

https://blog.csdn.net/fenghuoliuxing990124/article/details/84983694

 

 

基于.Net Core的Redis:基本数据类型及其应用场景与命令行操作

基于.Net Core的Redis:基本数据类型及其应用场景与命令行操作

1 using ServiceStack.Redis; 2 using System; 3 using System.Collections.Generic; 4 using System.Text; 5 6 namespace RedisDemo 7 { 8 class StringDemo 9 { 10 public static void Start() 11 { 12 var redisMangement = new RedisManagerPool("127.0.0.1:6379"); 13 var client = redisMangement.GetClient(); 14 15 //---字符串--- 16 //set key value 17 //summary: Set the string value of a key 18 client.Set<int>("pwd", 111); 19 //get key 20 //summary: Get the value of a key 21 int pwd = client.Get<int>("pwd"); 22 Console.WriteLine(pwd); 23 24 //---对象--- 25 var todos = client.As<Todo>(); 26 Todo todo = new Todo 27 { 28 Id = todos.GetNextSequence(), 29 Content = "String Demo", 30 Order = 1 31 }; 32 client.Set<Todo>("todo", todo); 33 var getTodo = client.Get<Todo>("todo"); 34 Console.WriteLine(getTodo.Content); 35 } 36 } 37 }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpzzdd.html