views:

18

answers:

1

hi all,

I am building a web application using asp.net (c#) and lingtosql. When I perform update operations on my db I update my classes. I use gridview to bind to update information. When I relay solely on the database the page's take very long to load. When I relay solely on the cache, I have old data. What workarounds do I have for have asynchronous cache updating, yet not overload the database with endless requests (I'd like to update the cache only if there has been a change in the database itself, and perform the update operation asynchronously).

Thanks alot,

A: 

You can have something like if the cache was inactive in a certain time(e.g. 30 minuntes) it'll refresh the data from the database.

Cache.Insert("CachedData", dt, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));

or you can refresh the data on cache every certain number of time. Check Cache Object.

Else, if you need something like cache will refresh it's data from the database only when there's any updates you might want to check SqlCacheDependency Object.

koderoid