首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> ASP.NET 基礎 >> 關於ASP.NET

ASP.NET 2.0 快取與 SqlCacheDependency 進階:輸出快取、資料快取、SQL 相依性完整配置

     編輯:關於ASP.NET

系統整理 ASP.NET 2.0 快取三大支柱與 SQL 快取失效機制。

@OutputCache 關鍵屬性

  • Duration:秒數。
  • VaryByParam:依 POST/GET 參數變化(多參數用分號)。
  • VaryByControl:依用戶控制項屬性變化(控制項 ID)。
  • CacheProfile:引用 web.config 定義的快取設定檔。

資料快取 API

Cache.Insert(key, value, dependencies, absoluteExpiration, slidingExpiration) 手動管理,支援檔案/鍵/時間相依性。

替換快取

<asp:Substitution> 回呼函數必須 static,用於快取頁面中插入動態片段。

SqlCacheDependency 配置

SQL Server 2005+(查詢通知,無需輪詢):

<sqlCacheDependency enabled="true" />

SQL Server 2000(輪詢機制):

<sqlCacheDependency enabled="true" pollTime="輪詢毫秒">
  <databases>
    <add name="名字" connectionStringName="連線字串名" />
  </databases>
</sqlCacheDependency>

並執行 aspnet_regsql.exe -S "server" -E -d "db" -ed 啟用資料庫,-et -t "table" 啟用資料表。

SQL 驗證請將 -E 換為 -U user -P pwd。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved