Cache Policy Advice

Discussion in 'ASP .Net' started by Weston Weems, Jan 4, 2005.

  1. Weston Weems

    Weston Weems Guest

    I attempted to post this yesterday however I dont see that
    it ever made it up. If this is an error on my part, I
    apologize in advance.

    I've got a webapp with somewhat trivial amount of data,
    however aquiring the data from the database usually takes
    approximately 1.5minutes. So first thing that pops into my
    head is cache it.

    What I'd like to do is load the cache up on
    Application_Start, then refresh every 4hrs or so. I'd like
    to avoid handling it lazily, because that guarentees one
    person will need to wait 1.5 minutes, whereas if it was
    just refreshed every 4hrs on the backend, that condition
    may occur, and it may not.

    I've got no problem loading up data on application_start,
    and set a CacheItemRemovedCallBack to execute a method to
    reload the cache with the data. The problem I am
    encountering is that I cant get a HttpContext to pull the
    cache object from.

    Should I be doing this a better way, or anyone have any
    sort of advice whatsoever? Source samples?

    Thanks in advance,
    Weston Weems
    Weston Weems, Jan 4, 2005
    #1
    1. Advertising

  2. Weston,

    Where exactly in the code are you having a problem with retrieving the
    HttpContext instance?

    :DG<

    "Weston Weems" <> wrote in message
    news:049001c4f27e$1ae5ded0$...
    >I attempted to post this yesterday however I dont see that
    > it ever made it up. If this is an error on my part, I
    > apologize in advance.
    >
    > I've got a webapp with somewhat trivial amount of data,
    > however aquiring the data from the database usually takes
    > approximately 1.5minutes. So first thing that pops into my
    > head is cache it.
    >
    > What I'd like to do is load the cache up on
    > Application_Start, then refresh every 4hrs or so. I'd like
    > to avoid handling it lazily, because that guarentees one
    > person will need to wait 1.5 minutes, whereas if it was
    > just refreshed every 4hrs on the backend, that condition
    > may occur, and it may not.
    >
    > I've got no problem loading up data on application_start,
    > and set a CacheItemRemovedCallBack to execute a method to
    > reload the cache with the data. The problem I am
    > encountering is that I cant get a HttpContext to pull the
    > cache object from.
    >
    > Should I be doing this a better way, or anyone have any
    > sort of advice whatsoever? Source samples?
    >
    > Thanks in advance,
    > Weston Weems
    Dimitri Glazkov, Jan 4, 2005
    #2
    1. Advertising

  3. Use System.Web.HttpRuntime.Cache. This static property of the Application
    class returns the Cache.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "Weston Weems" <> wrote in message
    news:049001c4f27e$1ae5ded0$...
    >I attempted to post this yesterday however I dont see that
    > it ever made it up. If this is an error on my part, I
    > apologize in advance.
    >
    > I've got a webapp with somewhat trivial amount of data,
    > however aquiring the data from the database usually takes
    > approximately 1.5minutes. So first thing that pops into my
    > head is cache it.
    >
    > What I'd like to do is load the cache up on
    > Application_Start, then refresh every 4hrs or so. I'd like
    > to avoid handling it lazily, because that guarentees one
    > person will need to wait 1.5 minutes, whereas if it was
    > just refreshed every 4hrs on the backend, that condition
    > may occur, and it may not.
    >
    > I've got no problem loading up data on application_start,
    > and set a CacheItemRemovedCallBack to execute a method to
    > reload the cache with the data. The problem I am
    > encountering is that I cant get a HttpContext to pull the
    > cache object from.
    >
    > Should I be doing this a better way, or anyone have any
    > sort of advice whatsoever? Source samples?
    >
    > Thanks in advance,
    > Weston Weems
    Kevin Spencer, Jan 4, 2005
    #3
  4. Weston Weems

    Weston Weems Guest

    I've set up

    MyNamespace.Caching - as a simple class that contains a
    few methods to set/purge cache items, as well as
    containing CacheItemRemovedCallBack.

    I do MyCache.Caching.AddCacheItem(object item)

    which will insert with a expriation of now+4hrs, and a
    CacheItemRemovedCallBack which is also in my Caching
    namespace.

    The problem is it loads initially, but when it goes to
    refresh, it gives me a null reference exception for some
    strange reason.

    If I've got the wrong idea, does anyone have examples of
    how one might achieve this?

    thank you very much.
    Weston Weems












    >-----Original Message-----
    >Weston,
    >
    >Where exactly in the code are you having a problem with

    retrieving the
    >HttpContext instance?
    >
    >:DG<
    >
    >"Weston Weems" <>

    wrote in message
    >news:049001c4f27e$1ae5ded0$...
    >>I attempted to post this yesterday however I dont see

    that
    >> it ever made it up. If this is an error on my part, I
    >> apologize in advance.
    >>
    >> I've got a webapp with somewhat trivial amount of data,
    >> however aquiring the data from the database usually

    takes
    >> approximately 1.5minutes. So first thing that pops into

    my
    >> head is cache it.
    >>
    >> What I'd like to do is load the cache up on
    >> Application_Start, then refresh every 4hrs or so. I'd

    like
    >> to avoid handling it lazily, because that guarentees one
    >> person will need to wait 1.5 minutes, whereas if it was
    >> just refreshed every 4hrs on the backend, that condition
    >> may occur, and it may not.
    >>
    >> I've got no problem loading up data on

    application_start,
    >> and set a CacheItemRemovedCallBack to execute a method

    to
    >> reload the cache with the data. The problem I am
    >> encountering is that I cant get a HttpContext to pull

    the
    >> cache object from.
    >>
    >> Should I be doing this a better way, or anyone have any
    >> sort of advice whatsoever? Source samples?
    >>
    >> Thanks in advance,
    >> Weston Weems

    >
    >
    >.
    >
    Weston Weems, Jan 4, 2005
    #4
  5. Weston Weems

    Weston Weems Guest

    Thank you this was exactly the sort of thing I was looking
    for.
    I'll give it a whirl.



    >-----Original Message-----
    >Use System.Web.HttpRuntime.Cache. This static property of

    the Application
    >class returns the Cache.
    >
    >--
    >HTH,
    >
    >Kevin Spencer
    >Microsoft MVP
    >..Net Developer
    >Neither a follower nor a lender be.
    >
    >"Weston Weems" <>

    wrote in message
    >news:049001c4f27e$1ae5ded0$...
    >>I attempted to post this yesterday however I dont see

    that
    >> it ever made it up. If this is an error on my part, I
    >> apologize in advance.
    >>
    >> I've got a webapp with somewhat trivial amount of data,
    >> however aquiring the data from the database usually

    takes
    >> approximately 1.5minutes. So first thing that pops into

    my
    >> head is cache it.
    >>
    >> What I'd like to do is load the cache up on
    >> Application_Start, then refresh every 4hrs or so. I'd

    like
    >> to avoid handling it lazily, because that guarentees one
    >> person will need to wait 1.5 minutes, whereas if it was
    >> just refreshed every 4hrs on the backend, that condition
    >> may occur, and it may not.
    >>
    >> I've got no problem loading up data on

    application_start,
    >> and set a CacheItemRemovedCallBack to execute a method

    to
    >> reload the cache with the data. The problem I am
    >> encountering is that I cant get a HttpContext to pull

    the
    >> cache object from.
    >>
    >> Should I be doing this a better way, or anyone have any
    >> sort of advice whatsoever? Source samples?
    >>
    >> Thanks in advance,
    >> Weston Weems

    >
    >
    >.
    >
    Weston Weems, Jan 4, 2005
    #5
  6. Weston Weems

    Weston Weems Guest

    Thank you, that worked perfectly!
    Weston


    >-----Original Message-----
    >Use System.Web.HttpRuntime.Cache. This static property of

    the Application
    >class returns the Cache.
    >
    >--
    >HTH,
    >
    >Kevin Spencer
    >Microsoft MVP
    >..Net Developer
    >Neither a follower nor a lender be.
    >
    >"Weston Weems" <>

    wrote in message
    >news:049001c4f27e$1ae5ded0$...
    >>I attempted to post this yesterday however I dont see

    that
    >> it ever made it up. If this is an error on my part, I
    >> apologize in advance.
    >>
    >> I've got a webapp with somewhat trivial amount of data,
    >> however aquiring the data from the database usually

    takes
    >> approximately 1.5minutes. So first thing that pops into

    my
    >> head is cache it.
    >>
    >> What I'd like to do is load the cache up on
    >> Application_Start, then refresh every 4hrs or so. I'd

    like
    >> to avoid handling it lazily, because that guarentees one
    >> person will need to wait 1.5 minutes, whereas if it was
    >> just refreshed every 4hrs on the backend, that condition
    >> may occur, and it may not.
    >>
    >> I've got no problem loading up data on

    application_start,
    >> and set a CacheItemRemovedCallBack to execute a method

    to
    >> reload the cache with the data. The problem I am
    >> encountering is that I cant get a HttpContext to pull

    the
    >> cache object from.
    >>
    >> Should I be doing this a better way, or anyone have any
    >> sort of advice whatsoever? Source samples?
    >>
    >> Thanks in advance,
    >> Weston Weems

    >
    >
    >.
    >
    Weston Weems, Jan 4, 2005
    #6
    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. Jeff Nokes

    Cache::Cache Stale Segments

    Jeff Nokes, Sep 30, 2003, in forum: Perl
    Replies:
    0
    Views:
    570
    Jeff Nokes
    Sep 30, 2003
  2. DesignerX

    Page.Cache vs HttpContext.Current.Cache

    DesignerX, Jan 20, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    8,242
    vMike
    Jan 20, 2004
  3. =?Utf-8?B?b25l?=
    Replies:
    1
    Views:
    5,280
    Karl Seguin [MVP]
    Mar 8, 2006
  4. Sergey via DotNetMonster.com

    ASP.NET Cache vs Window System Cache

    Sergey via DotNetMonster.com, Nov 15, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    474
    Sergey via DotNetMonster.com
    Nov 15, 2006
  5. helveticus

    Setting up a browser cache policy

    helveticus, May 6, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    471
    helveticus
    May 6, 2008
Loading...

Share This Page