redis存取值
//取值
//存值
//redis缓存 存值
[Route("api/cunzhi")]
[HttpGet]
public IHttpActionResult a(string pname, string address)
{
List<tb_ProcInfo> projects = new List<tb_ProcInfo> { new tb_ProcInfo {Pname=pname,Address=address } };
RedisClient client = new RedisClient("127.0.0.1", 6379);
for (int i = 0; i < projects.Count; i++)
{
client.EnqueueItemOnList("key", JsonConvert.SerializeObject(projects[i]));
}
return Ok(1);
}
//redis缓存 读取值
[Route("api/redis")]
[HttpGet]
public IHttpActionResult redis()
{
RedisClient client1 = new RedisClient("127.0.0.1", 6379);
var rlist = client1.LRange("key", 0, -1);
List<tb_ProcInfo> list = new List<tb_ProcInfo>();
foreach (var item in rlist)
{
string b = Encoding.UTF8.GetString(item);
tb_ProcInfo model = JsonConvert.DeserializeObject<tb_ProcInfo>(b);
list.Add(model);
}
return Ok(list);
}
[Route("api/cunzhi")]
[HttpGet]
public IHttpActionResult a(string pname, string address)
{
List<tb_ProcInfo> projects = new List<tb_ProcInfo> { new tb_ProcInfo {Pname=pname,Address=address } };
RedisClient client = new RedisClient("127.0.0.1", 6379);
for (int i = 0; i < projects.Count; i++)
{
client.EnqueueItemOnList("key", JsonConvert.SerializeObject(projects[i]));
}
return Ok(1);
}
//redis缓存 读取值
[Route("api/redis")]
[HttpGet]
public IHttpActionResult redis()
{
RedisClient client1 = new RedisClient("127.0.0.1", 6379);
var rlist = client1.LRange("key", 0, -1);
List<tb_ProcInfo> list = new List<tb_ProcInfo>();
foreach (var item in rlist)
{
string b = Encoding.UTF8.GetString(item);
tb_ProcInfo model = JsonConvert.DeserializeObject<tb_ProcInfo>(b);
list.Add(model);
}
return Ok(list);
}