.net 删除缓存的key中带有指定字符的方法
/// <summary>
/// 删除带有指定字符的缓存
/// </summary>
/// <param name="pre"></param>
public void Refresh(string pre)
{
System.Web.Caching.Cache _cache = HttpRuntime.Cache;
IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
ArrayList al = new ArrayList();
while (CacheEnum.MoveNext())
{
al.Add(CacheEnum.Key);
}
foreach (string key in al)
{
if (string.IsNullOrEmpty(pre))
{
_cache.Remove(key);
}
else
{
if (key.Contains(pre))
{
_cache.Remove(key);
}
}
}
}
#endregion