SQL輪詢數據依賴緩存

C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/aspnet_regsql.exe -S 服務器 -U 用戶名 -P 密碼 -ed -d 數據庫名 -et -t 表名 

以上命令啓用SQL輪詢數據依賴緩存

web.config的<system.web>節中添加以下配置

<!--SQL輪詢數據綬存-->
    <caching>
      <sqlCacheDependency enabled="true" pollTime="2000">
        <databases>
          <add name="webs" connectionStringName="websConnectionString" />
        </databases>
      </sqlCacheDependency>
    </caching>

(1)頁面輸出緩存中使用SQL輪詢依賴緩存

<% OutputCache Duration="時間"  SqlDependency="啓用的數據庫:表名" varyByParam="none">

(2)數據源中使用SQL輪詢緩存

<asp:SqlDataSource ID="sqlDataSource2" EnableCaching="true" SqlCacheDependency="啓用的數據庫名:表名"  SelectCommand="select id,name......" ConnectionString="<%$ConnectionString:mySqlServer%>" Runat="Server" />

(3)應用程序數據緩存

SqlCacheDependency scd=new SqlCacheDependency("webs","wareInfo");

Cache.Insert("TitleCount",count,scd);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章