c#读取redis中hash类型的数据        //linux服务器地址
static private string host = "127.0.0.1";
//static private string host = "127.0.0.1";
static private int port = 6376;
static RedisClient redisClient = new RedisClient(host, port);//redis服务IP和端⼝
private void RedisDemo_Load(object sender, EventArgs e)
{
redisClient.Password = "abcd+1234";//密码 没有可以注释
linux怎么读取文件var hashKeys = redisClient.GetHashKeys("h_license");  //获取key
foreach (var key in hashKeys)
{
Console.WriteLine("HashId--Key:{0}", key);
}
var haskValues = client.GetHashValues("h_license");//获取value
foreach (var value in haskValues)
{
Console.WriteLine("HashId--Value:{0}", value);
}
var allKeys = client.GetAllKeys(); //获取所有的key。
foreach (var key in allKeys)
{
Console.WriteLine("AllKey--Key:{0}", key);
}
var dic1 = redisClient.GetAllEntriesFromHash("h_license");//同时获取key和value
Console.WriteLine("Key-----Value");
foreach (var keyVal in dic1)
{
Console.WriteLine(string.Format("{0}-----{1}", keyVal.Key, keyVal.Value));
}
Console.ReadKey();
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。