I build an out-of-process cache for my webpage's database. Though when I try to do something with it (Set, Get), I get the following error:
A task was canceled
Here's my redis cache code. any help would be great. thanks
public class RedisCache : ICache
{
private RedisConnection redis;
public RedisCache()
{
redis = new RedisConnection("127.0.0.1");
redis.Open();
}
public object Get(string key)
{
var method = redis.Strings.Get(0, key);
if (method == null)
return null;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream(method.Result);
object obj = bf.Deserialize(ms);
return obj;
}
public void Set(string key, object value)
{
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, value);
redis.Strings.Set(0, key, ms.ToArray());
}
}