数据集更新时更新缓存 [英] Update the cache when dataset is updated

查看:104
本文介绍了数据集更新时更新缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储所有大洲及其各自国家的数据集.我正在缓存数据表:

I have a data set storing all continents with their respective countries. I am caching the data table:

DataSet dset = new DataSet();
string cacheKey = "CoverageDataTable";
object cacheItem = Cache[cacheKey] as DataTable;
if (cacheItem == null)
{
    dset = (DataSet)_obj.GetAllContinent();
    cacheItem = dset.Tables[0];
    Cache.Insert(cacheKey, cacheItem, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromHours(5), CacheItemPriority.High, null);
 }



现在,我希望如果数据表中有任何更改,那么应该从数据库中获取新数据.我该怎么做?



Now I want that if there is any change in the data table, fresh data should be fetched from the database. How can I do this?

推荐答案

我给您链接,希望对您有所帮助

ASP.NET中的高级数据缓存功能 [ ^ ]

在ASP.NET中探索缓存 [ ASP.NET缓存依赖项 [
i am giving you links i hope it will help you

Advanced Data Caching features in ASP.NET[^]

Exploring Caching in ASP.NET[^]

ASP.NET Caching Dependencies[^]


这篇关于数据集更新时更新缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆