Cache dependency on database select statement

Discussion in 'ASP .Net' started by martin, Oct 18, 2003.

  1. martin

    martin Guest

    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.
    martin, Oct 18, 2003
    #1
    1. Advertising

  2. It is possible, but not easy or graceful.
    Here's the details:
    http://msdn.microsoft.com/msdnmag/issues/03/04/WickedCode/default.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net
    Hire top-notch developers at http://www.able-consulting.com



    "martin" <> wrote in message
    news:...
    > 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.
    >
    >
    Steve C. Orr [MVP, MCSD], Oct 18, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wh

    cache dependency object

    wh, Apr 5, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    430
    Alvin Bruney [MVP]
    Apr 6, 2004
  2. Jason Dean

    Cache Dependency Question

    Jason Dean, Dec 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,749
    Jason Dean
    Dec 17, 2004
  3. Steffen Loringer

    Cache dependency for SQL database changed

    Steffen Loringer, May 17, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    408
    Eliyahu Goldin
    May 17, 2005
  4. =?Utf-8?B?RGlmZmlkZW50?=

    Dependency of a cache object to oracle

    =?Utf-8?B?RGlmZmlkZW50?=, Jan 11, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    607
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Jan 11, 2006
  5. =?Utf-8?B?WXV2YQ==?=

    Failed creating table cache dependency registration

    =?Utf-8?B?WXV2YQ==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    597
    =?Utf-8?B?WXV2YQ==?=
    May 9, 2006
Loading...

Share This Page