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

推荐订阅源

W
WeLiveSecurity
Jina AI
Jina AI
博客园 - 司徒正美
雷峰网
雷峰网
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园_首页
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
美团技术团队
I
InfoQ
博客园 - Franky
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
Cyberwarzone
Cyberwarzone
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security
P
Privacy & Cybersecurity Law Blog
T
Threatpost
Cloudbric
Cloudbric
D
Docker
M
MIT News - Artificial intelligence
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Vercel News
Vercel News
Martin Fowler
Martin Fowler
J
Java Code Geeks
AWS News Blog
AWS News Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
L
Lohrmann on Cybersecurity
Hacker News: Ask HN
Hacker News: Ask HN
Last Week in AI
Last Week in AI
S
Security @ Cisco Blogs
Help Net Security
Help Net Security
C
Cisco Blogs
V
V2EX
博客园 - 【当耐特】
I
Intezer
爱范儿
爱范儿
F
Fortinet All Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Privacy International News Feed
IT之家
IT之家
L
LINUX DO - 最新话题
B
Blog RSS Feed
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 子风

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

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