Cache dependency on database select statement

M

martin

Hi,

I have a page that contain a dropdown list of values.
This drop down list rarely changes so I wish to cache the page. However the
values in the dropdown box are taken from a database, so if the values in
the database change I wish to expire the cache and go to the database again
and get a fresh copy.

I have worked out that I should use one of the methods of cache.insert that
take a cache dependency object, for example

public void Insert(
string key,
object value,
CacheDependency dependencies,
DateTime absoluteExpiration,
TimeSpan slidingExpiration
);

However I am not sure how to create the cachedependency object from an
sqlstatement, and conect it to my database. my db is sql server 2000, the
select satement is of the form "select catID,CatName from category" and only
references a single table.

I have been able to create a cachedependency object that relies on an XML
file

dim objCache as new cachedependency(server.mapath(/myXMLfile))

however I am stumped creating a dependency on a database, is this possible,
Iwould be gratefull for any advice on how to do this.

cheers

martin.
 

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

Top