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

推荐订阅源

T
Troy Hunt's Blog
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta
F
Full Disclosure
Recorded Future
Recorded Future
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
博客园_首页
博客园 - 叶小钗
MongoDB | Blog
MongoDB | Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Hacker News: Front Page
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
博客园 - 司徒正美
Webroot Blog
Webroot Blog
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security
Cloudbric
Cloudbric
PCI Perspectives
PCI Perspectives
有赞技术团队
有赞技术团队
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
L
Lohrmann on Cybersecurity
量子位
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tailwind CSS Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
P
Proofpoint News Feed
N
News and Events Feed by Topic
罗磊的独立博客
T
Threat Research - Cisco Blogs
Schneier on Security
Schneier on Security
T
Tor Project blog
IT之家
IT之家
M
MIT News - Artificial intelligence
S
Security @ Cisco Blogs
O
OpenAI News
AI
AI
S
Securelist
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
月光博客
月光博客
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题

博客园 - 子风

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

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