当前位置:Gxlcms > 数据库问题 > C# Redis数据库 一:部署安装及操作

C# Redis数据库 一:部署安装及操作

时间:2021-07-01 10:21:17 帮助过:5人阅读

using ServiceStack.Redis; //引包 2 class Program 3 { 4 //创建Redis操作对象 5 static RedisClient client = new RedisClient("127.0.0.1", 6379); 6 static void Main(string[] args) 7 { 8 //存储数据 9 client.Set<string>("Name", "admin"); 10 client.Set<string>("PassWord","123456"); 11 12 //判断是否存在指定的Key值 13 bool isKey = client.ContainsKey("Name"); 14 15 //取数据 16 string name = client.Get<string>("Name"); 17 string passWord = client.Get<string>("PassWord"); 18 19 Console.WriteLine("是否存在Name值:{0}\nNmae值:{1}\nPassWord值:{2}", isKey, name, passWord); 20 21 Console.ReadKey(); 22 } 23 }

  运行效果

技术图片

 

  以上只是基本的写读操作

C# Redis数据库 一:部署安装及操作

标签:控制台   down   key值   nbsp   ram   管理   安装   files   安装完成   

人气教程排行