Page data caching

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?
 
S

Scott Allen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top