操纵 VirtualPathProvider 缓存

Manipulation VirtualPathProvider cache

我正在构建一个依赖于 VirtualPathProvider 的 cms 系统。 我需要显示能够释放此缓存的兑现页面。 这是构建缓存的代码。 我怎样才能访问这个缓存?显示缓存页面列表

public override CacheDependency GetCacheDependency(
string virtualPath, 
System.Collections.IEnumerable virtualPathDependencies, 
DateTime utcStart)
{
  if (IsPathVirtual(virtualPath))
  {
System.Collections.Specialized.StringCollection fullPathDependencies = null;

// Get the full path to all dependencies. 
foreach (string virtualDependency in virtualPathDependencies)
{
  if (fullPathDependencies == null)
    fullPathDependencies = new System.Collections.Specialized.StringCollection();

  fullPathDependencies.Add(virtualDependency);
}
if (fullPathDependencies == null)
  return null;

// Copy the list of full-path dependencies into an array. 
string[] fullPathDependenciesArray = new string[fullPathDependencies.Count];
fullPathDependencies.CopyTo(fullPathDependenciesArray, 0);
// Copy the virtual path into an array. 
string[] virtualPathArray = new string[1];
virtualPathArray[0] = virtualPath;

return new CacheDependency(virtualPathArray, fullPathDependenciesArray, utcStart);
}
else 
return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
}

问题已通过创建 CustomeCacheDependency 解决

 public override CacheDependency GetCacheDependency(string virtualPath,
        System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
    {
         if (IsPathVirtual(virtualPath))
             {
                  return CashManager.SetPageCash(virtualPath);
             }
        return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
    }



public class SecuHostCacheDependency: System.Web.Caching.CacheDependency
{
    public CustomeCacheDependency()
    {
        base.SetUtcLastModified(DateTime.UtcNow);
    }
    public void Clear()
    {
         base.SetUtcLastModified(DateTime.UtcNow);
        NotifyDependencyChanged(this, EventArgs.Empty);
    }
}

public class CashManager
{
    // Page Cash
    public static CustomeCacheDependency SetPageCash(string url)
    {
       CustomeCacheDependency customeCacheDependency = new CustomeCacheDependency ();
 System.Web.HttpContext.Current.Application[url]=customeCacheDependency;


        return customeCacheDependency;
    }
    public static void ClearPageCash(string url)
    {
        CustomeCacheDependency  customeCacheDependency=
   System.Web.HttpContext.Current.Application[url] as customeCacheDependency;
        if (CustomeCacheDependency != null)
        {
          CustomeCacheDependency.Clear();
        }
    }
}