惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
PCI Perspectives
PCI Perspectives
H
Help Net Security
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网
S
Secure Thoughts
Jina AI
Jina AI
Attack and Defense Labs
Attack and Defense Labs
大猫的无限游戏
大猫的无限游戏
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Security @ Cisco Blogs
阮一峰的网络日志
阮一峰的网络日志
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
T
Tor Project blog
小众软件
小众软件
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
博客园 - 【当耐特】
G
Google Developers Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
I
Intezer
S
Schneier on Security
S
Securelist
W
WeLiveSecurity
C
Cybersecurity and Infrastructure Security Agency CISA
P
Palo Alto Networks Blog
Scott Helme
Scott Helme
Project Zero
Project Zero
Google Online Security Blog
Google Online Security Blog
T
Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Engineering at Meta
Engineering at Meta
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
Last Week in AI
Last Week in AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
A
Arctic Wolf
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LangChain Blog

博客园 - Jun1st

Application之间共享Master Page ASP.NET AJAX 4的Client-Side Template和DataView ASP.NET AJAX 4的Client-Side Template和DataView 体验ASP.NET4之ClientID 体验ASP.NET 4之URL Routing 使用Extension Methods来使IDataReader更加方便 Custom WCF Configuration File USE HttpRuntime.Cache OVER HttpContext.Current.Cache Make Asynchronous Calls from Page IIS and VS Embedded Local Web Server Integrate jQuery with ASP.NET Data Controls Tech-Ed 2008 上海 ASP.NET MVC的分页和导航 LINQ and Pipeline Pattern Why Would a .Net Programmer Learn Ruby On Rails(翻译) ASP.NET MVC之AJAX Asp.Net MVC---Walkthrough Asp.Net MVC 入门篇——Overview Security Basics and ASP.NET Support(翻译)
Asp.Net 2.0之SqlCacheDependency
Jun1st · 2008-03-14 · via 博客园 - Jun1st

2008-03-14 01:09  Jun1st  阅读(1525)  评论()    收藏  举报

Introduction

ASP.NET 2.0提供了一些新的用于提升程序性能的技术特性,其中,缓存技术是非常重要的一个特性,它提供了一种非常好的本地数据缓存机制,可以非常容易的定制属于数据缓从,从而有效的提高数据访问的性能。本文将介绍一下SqlCacheDenendency.

1. Page&Source Code

为了简单起见,示例就是用Sql Server的Sample数据库。新建一个Asp.net 2.0或者3.0,3.5的Web site之后,在一个web form上,添加一个GridView, 并配置一个SqlDataSource, 适当的选择几个column,如图:

注意:需要设置SqlDataSource的EnableCaching属性为true,才能实现Cache。除此之外,还需要设置SqlCacheDependency为:Northwind:Employees,如果有多个数据库表要实现这种dependency, 多个表之间以分号分隔。

2.配置文件

<system.web>这个config节点之间需要加上如下配置代码:

<caching>

<sqlCacheDependency enabled="true">

<databases>

<add name="Northwind" connectionStringName="NorthwindConnectionString" pollTime="1000"/>

</databases>

</sqlCacheDependency>

</caching>

使用的connectionStringName为任何一个可以连接到所用数据库的连接。pollTime为轮训更新的时间间隔,为了测试方便,把pollTime设置为1000。

3.启用数据库的SqlCacheDependency

使用如下命令行启用数据库的CacheDependency属性:

    aspnet_regsql -E -ed -d Northwind -et -t Employees

-E:表示使用Windows集成验证。

4.测试

先run application,显示数据,再更改一下数据库数据,再刷新一下页面,就可以看到更新的数据了。

Summary

比较简单,呵呵,请"园友"们多多指教。