参考自:https://blog.csdn.net/only_yu_yy/article/details/78873735
https://blog.csdn.net/fenghuoliuxing990124/article/details/84983694
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 }