本章从缓存所在的命名空间“System.Web.Caching”开始,详细介绍框架提供的缓存类和操作方法,主要涉及简单数据的缓存、数据缓存依赖和数据库缓存依赖三个技术要点,最后演示一个完全使用缓存实现数据读取的实例。 16.1 System.Web.Caching简介 本节从缓存命名空间的总体简介和组成结构入手,从整体上对System.Web.Caching进行...
使用绝对到期,则可调到期值必须为System.Web.Caching.Cache.NoSlidingExpiration,禁用可调到期。 反之,使用可调到期,则绝对到期的值必须为System.Web.Caching.Cache.NoAbsoluteExpiration,禁用绝对到期。 Insert方法和Add方法的参数是一样的,不过Insert方法提供了更多的重载,如果你不提供某个值,那这个值就会被设置为默认值。
System.Web.Caching 程序集: System.Web.dll 实现Web 应用程序的缓存。 此类不能被继承。 C#复制 publicsealedclassCache:System.Collections.IEnumerable 继承 Object Cache 实现 IEnumerable 示例 以下示例是一个页面,它向用户显示分配给缓存中的项的值,然后在从缓存中删除该项时通知用户。 它创建一个RemovedCallback...
System.Web.Caching 程序集: System.Web.dll 实现Web 应用程序的缓存。 此类不能被继承。 C#复制 publicsealedclassCache:System.Collections.IEnumerable 继承 Object Cache 实现 IEnumerable 示例 以下示例是一个页面,它向用户显示分配给缓存中的项的值,然后在从缓存中删除该项时通知用户。 它创建一个RemovedCallback...
System.Web.Caching 程序集: System.Web.dll 可通过编程方式访问网站的配置文件中指定的输出缓存提供程序。 C#复制 publicstaticclassOutputCache 继承 Object OutputCache 注解 输出缓存将生成的页面、控件和 HTTP 响应的输出存储在内存中。 使用输出缓存可以缓存不同版本的内容,具体取决于查询字符串、页面上的窗体发布参...
System.Web.Caching 程序集: System.Web.dll 在存储于 ASP.NET 应用程序的Cache对象中的项与文件、缓存键、文件或缓存键的数组,或另一个CacheDependency对象之间建立依赖关系。CacheDependency类监视依赖关系,以便在任何这些对象发生更改时,自动删除缓存的项。
public void Insert (string key, object value, System.Web.Caching.CacheDependency dependencies); 参数 key String 用于标识该项的缓存键。 value Object 要插入缓存中的对象。 dependencies CacheDependency 所插入对象的文件依赖项或缓存键依赖项。 当任何依赖项更改时,该对象即无效,并从缓存中移除。 如果没...
publicvoidInsert(stringkey,objectvalue, System.Web.Caching.CacheDependency dependencies); 參數 key String 用來識別項目的快取索引鍵。 value Object 要插入至快取的物件。 dependencies CacheDependency 插入物件的檔案或快取索引鍵相依性。 任何相依性變更時,物件會變成無效並從快取中移除。 如果沒有相依性,這個...
Web.Caching Assembly: System.Web.dll Implements the cache for a Web application. This class cannot be inherited. C# Copy public sealed class Cache : System.Collections.IEnumerable Inheritance Object Cache Implements IEnumerable Examples The following example is a page that shows users the ...
Web.Caching Assembly: System.Web.dll Implements the cache for a Web application. This class cannot be inherited. C# Copy public sealed class Cache : System.Collections.IEnumerable Inheritance Object Cache Implements IEnumerable Examples The following example is a page that shows users the ...