try
{
IDictionaryEnumerator DicCache = HttpRuntime.Cache.GetEnumerator();
int count = HttpRuntime.Cache.Count;
for (int i = 0; i < count; i++)
{
DicCache.MoveNext();
HttpRuntime.Cache.Remove(DicCache.Entry.Key.ToString());
}
}
catch (Exception)
{
throw;
}
试试下面的代码
try
{
IDictionaryEnumerator DicCache = HttpRuntime.Cache.GetEnumerator();
while(DicCache.MoveNext())
{
HttpRuntime.Cache.Remove(DicCache.Entry.Key.ToString());
}
}
catch (Exception)
{
throw;
}
谢谢,.net core 里面好像没有类似的方法是吗?
@weisp: 你那边 .NET Core 中有 HttpRuntime.Cache ?
@dudu: IMemoryCache 没办法向以前一样简单得到所有缓存好像
@weisp: 可以使用 EnyimMemcachedCore ,通过 IMemcachedClient.FlushAllAsync()
清除所有缓存