我在
下写了一个缓存扩展代码public class RedisManager:ICacheManager
{
private readonly RedisClient _client;
public RedisManager()
{
_client = new RedisClient("127.0.0.1", 6379);
}
public T Get<T>(string key)
{
return _client.Get<T>(key);
}
public void Set(string key, object data, int cacheTime)
{
_client.Add(key, data);
}
public bool IsSet(string key)
{
return _client.ContainsKey(key);
}
public void Remove(string key)
{
_client.Remove(key);
}
public void RemoveByPattern(string pattern)
{
_client.RemoveByPattern(pattern);
}
public void Clear()
{
_client.FlushDb();
}
}
然后修改配置
builder.RegisterType<RedisManager>().As<ICacheManager>().Named<ICacheManager>("nop_redis_cache_static").SingleInstance();
但在运行错误后,错误是:
未处理的异常“System.StackOverflowException”类型的位置 System.Web.dll中
我们如何解决?