Page data caching

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

I'm adding data to the cache with this code:
HttpContext.Current.Cache( "Categories" ) = GetCategoriesFromDB

The problem is wheneveeeer I modify the database, the cache doesn't change
quickly enough. I looked at using a SQL Severer trigger to clear it by using
a cache trigger dependency. But all I really need to do is clear it after a
few minutes.
Can someone guide me?
 
Hi Mark:

If you use the Insert method, you'll have greater control over the
expiration settings:

Cache.Insert("Categories", GetCategoriesFromDB(), Nothing, _
DateTime.Now.AddMinutes(2), TimeSpan.Zero)

The above will cache the object for 2 minutes.
 
Back
Top