public string GetData(int value)
{
try
{
string host = "localhost";
string message = string.Empty;
//IRedisClient client = await RedisClient.ConnectAsync("127.0.0.1", 6379);
string elementKey = "testKeyRedis";
//using (RedisClient redisClient = new RedisClient(host))
//{
// if (redisClient.Get(elementKey) == null)
// {
// // adding delay to see the difference
// //Thread.Sleep(5000);
// redisClient.Set(elementKey, "some cached value");
// }
// message = "data from" + redisClient.Get<string>(elementKey);
//}
using (RedisClient redisClient = new RedisClient(host))
{
//file system xml file reading
String Result;
XElement xmlDoc = null;
string key = "key";
xmlDoc = XElement.Load("file.xml");
XElement xmlResult;
redisClient.SetEntryInHash("urn:dateTime", key, xmlDoc.ToString());
var hash = redisClient.GetAllEntriesFromHash("urn:dateTime");
xmlResult = XElement.Parse(hash[key]);
//xmlResult = hash[key] as XElement;
//if (redisClient.Set(key, xmlDoc))
// xmlResult = redisClient.Get<object>(key) as XElement;
}
return string.Format("Returning from redis", message);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
Console.Read();
return "Exception";
}
}
{
try
{
string host = "localhost";
string message = string.Empty;
//IRedisClient client = await RedisClient.ConnectAsync("127.0.0.1", 6379);
string elementKey = "testKeyRedis";
//using (RedisClient redisClient = new RedisClient(host))
//{
// if (redisClient.Get(elementKey) == null)
// {
// // adding delay to see the difference
// //Thread.Sleep(5000);
// redisClient.Set(elementKey, "some cached value");
// }
// message = "data from" + redisClient.Get<string>(elementKey);
//}
using (RedisClient redisClient = new RedisClient(host))
{
//file system xml file reading
String Result;
XElement xmlDoc = null;
string key = "key";
xmlDoc = XElement.Load("file.xml");
XElement xmlResult;
redisClient.SetEntryInHash("urn:dateTime", key, xmlDoc.ToString());
var hash = redisClient.GetAllEntriesFromHash("urn:dateTime");
xmlResult = XElement.Parse(hash[key]);
//xmlResult = hash[key] as XElement;
//if (redisClient.Set(key, xmlDoc))
// xmlResult = redisClient.Get<object>(key) as XElement;
}
return string.Format("Returning from redis", message);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
Console.Read();
return "Exception";
}
}
Post a Comment
Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.