C# redis简单的使用
2020-12-13 15:14
标签:style blog io color ar os 使用 for sp 1、项目一:用于在Redis中添加数据 2、项目二:用于访问项目一Redis中的数据 C# redis简单的使用 标签:style blog io color ar os 使用 for sp 原文地址:http://www.cnblogs.com/zoro-zero/p/4072936.htmlusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ServiceStack.Redis;
namespace RedisTest
{
class Program
{
static void Main(string[] args)
{
var client = new RedisClient("172.16.1.114", 6379);
//client.Set
>("userInfoList",list);
Console.WriteLine("ok");
Console.ReadKey();
}
}
public class UserInfo
{
public UserInfo()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
public int Id { get; set; }
public string UserName { get; set; }
public char Gender { get; set; }
public int Age { get; set; }
public string ToString()
{
return "Id=" + Id + ",UserName=" + UserName + ",Gender=" + Gender + ",Age=" + Age;
}
}
}
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ServiceStack.Redis;
using System.Collections.Generic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var client = new RedisClient("172.16.1.114", 6379);
List
>("userInfoList");
foreach (var item in list)
{
Response.Write(item.ToString());
Response.Write("
");
}
//UserInfo userInfo = new UserInfo() { Id = 111, UserName = "李四", Age = 45, Gender = ‘男‘ };
//var isAdd = client.Add
");
//UserInfo userinfo = client.Get
");
//client.Add
上一篇:python的JSON库
下一篇:C# JSON帮助类