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

推荐订阅源

S
Security @ Cisco Blogs
罗磊的独立博客
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
美团技术团队
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
博客园 - Franky
G
Google Developers Blog
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
V
Visual Studio Blog
腾讯CDC
S
SegmentFault 最新的问题
Recent Announcements
Recent Announcements
博客园 - 叶小钗
Microsoft Security Blog
Microsoft Security Blog
雷峰网
雷峰网
L
LangChain Blog
Vercel News
Vercel News
Forbes - Security
Forbes - Security
PCI Perspectives
PCI Perspectives
N
News | PayPal Newsroom
S
Security Affairs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 司徒正美
J
Java Code Geeks
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hacker News: Ask HN
Hacker News: Ask HN
Schneier on Security
Schneier on Security
A
About on SuperTechFans
Attack and Defense Labs
Attack and Defense Labs
Google Online Security Blog
Google Online Security Blog
aimingoo的专栏
aimingoo的专栏
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
Cloudbric
Cloudbric
B
Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Proofpoint News Feed
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic

博客园 - 子风

Android相关转载帖子 c++ 函数的工作原理 C和C++的存储模式 VS2005配置开发ARM c++ 虚析构函数的思考 arm-linux-g++ 下交叉编译libxml2 (转)Eclipse代码提示功能设置(Java & C/C++) linux下面eclipse的c++配置 VS2008 配置boost 用VS.NET2008打包程序遇到不可恢复的生成错误的解决方案 推荐一个原型的设计软件 Mockups For Desktop Grid++Report——推模式下填充子报表 c# 对象的创建过程 Failure sending mail - 子风 XP下IIS错误:Server Application Error css总结 .net 测试工具 .net 发送Email 利用7z来分卷压缩文件
asp.net缓存-数据依赖缓存 - 子风 - 博客园
子风 · 2010-03-19 · via 博客园 - 子风

    由于项目有用到Cache这块知识,这里总结一下。

   在Vs2008 Vc  窗口下运行 aspnet_regsql -C "server= (local)\tadb;database=abico;uid= sa;pwd =" -ed -et -t "Events"

   会在你的Database建立一个AspNet_SqlCacheTablesForChangeNotification 这个表,还有若干个存储过程。

   在Web.config 中配置下缓存的信息

配置信息

<appSettings/>
 
<connectionStrings>
  
<add name="testCache" connectionString="data source = 127.0.0.1;initial catalog = abico;user id = sa ;password =135246 " providerName="System.Data.SqlClient"/>
 
</connectionStrings>

代码

<system.web>
    
<caching>
            
<sqlCacheDependency enabled="true" pollTime="1000">
                
<databases>
                    
<add name="abico" connectionStringName="testCache"/>
                
</databases>
            
</sqlCacheDependency>

其中pollTime 是轮询数据库的时间,默认是1分钟,单位毫秒。这个参数很重要,类似定时器功能,应用程式会根据这个时间定时的去轮询你的数据库,获取你的table是否有更新。

如果不在 Web.config中配置,也可以写在SqlCacheDependencyAdmin这个类中。

如果想对多个表进行缓存:

1)在AspNet_SqlCacheTablesForChangeNotification表中,新增一条记录 tabName 就是你要缓存的表

2)SqlCacheDependencyAdmin.EnableTableForNotifications(conString, "QX_User");第一个参数是连接字符串,第二个是要缓存的表名。

主要一点是你的缓存依赖性 要写对表名

SqlCacheDependency dep = new SqlCacheDependency("abico", "QX_User"); abico:数据库名,QX_User:表名。

------------------------------------------------------

我理解的Cache 就是.net自己做好了一个定时器根据PollTime时间去轮询数据库,调用存储过程,知道表的AspNet_SqlCacheTablesForChangeNotification的信息,里面有标记ChangeID。当ChangeID改变时,有回调函数的就触发回调函数,没有的话就把现有的缓存删除了。

-------------------------------------------------------

DEMO下载 /Files/86188281/CacheTest.rar

学习,积累中......