Cache an object

Discussion in 'ASP .Net' started by Prashanth, Jun 20, 2006.

  1. Prashanth

    Prashanth Guest

    Hi,
    I want to cache an object whose scope in only within the page. The
    cache should expire once the user leaves the page. How can I do it?
    Regards,
    Prashanth
    Prashanth, Jun 20, 2006
    #1
    1. Advertising

  2. Prashanth

    sloan Guest

    The 3 main ways to cache objects are:

    Application
    Session
    Context

    http://msdn2.microsoft.com/en-us/library/system.web.ui.page.context.aspx

    Context gives you a "one time shot" at getting the values.

    It may not be exactly what you looking for, however, those are the main 3,
    and Context is the closest one to your description.


    If you look at my blog:

    You can use my Session Object Wrapper, and my .Remove method.

    http://sholliday.spaces.msn.com/PersonalSpace.aspx 10/24/2005 entry



    "Prashanth" <> wrote in message
    news:...
    > Hi,
    > I want to cache an object whose scope in only within the page. The
    > cache should expire once the user leaves the page. How can I do it?
    > Regards,
    > Prashanth
    >
    sloan, Jun 20, 2006
    #2
    1. Advertising

  3. Sloan:
    You are missing the viewstate. I only mention it because it might be what's
    wanted in this case. "scope of the page" isn't particularly clear though, so
    it's hard to tell. Context is ideal for dealing with the start of page
    processing (say init) to the end (say prerender). If you want the data to
    survive a postback, you'll need to do something more persistant. ViewState
    might work, but it's rendered on the client so it needs to (1) be
    serializable and (2) be small.

    Karl

    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "sloan" <> wrote in message
    news:...
    >
    > The 3 main ways to cache objects are:
    >
    > Application
    > Session
    > Context
    >
    > http://msdn2.microsoft.com/en-us/library/system.web.ui.page.context.aspx
    >
    > Context gives you a "one time shot" at getting the values.
    >
    > It may not be exactly what you looking for, however, those are the main 3,
    > and Context is the closest one to your description.
    >
    >
    > If you look at my blog:
    >
    > You can use my Session Object Wrapper, and my .Remove method.
    >
    > http://sholliday.spaces.msn.com/PersonalSpace.aspx 10/24/2005 entry
    >
    >
    >
    > "Prashanth" <> wrote in message
    > news:...
    >> Hi,
    >> I want to cache an object whose scope in only within the page. The
    >> cache should expire once the user leaves the page. How can I do it?
    >> Regards,
    >> Prashanth
    >>

    >
    >
    Karl Seguin [MVP], Jun 20, 2006
    #3
  4. Prashanth

    sloan Guest

    Ooooops!

    You're right Karl... I forgot about that one!

    That's why I should answer posts that early in the morning.




    "Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
    net> wrote in message news:...
    > Sloan:
    > You are missing the viewstate. I only mention it because it might be

    what's
    > wanted in this case. "scope of the page" isn't particularly clear though,

    so
    > it's hard to tell. Context is ideal for dealing with the start of page
    > processing (say init) to the end (say prerender). If you want the data to
    > survive a postback, you'll need to do something more persistant. ViewState
    > might work, but it's rendered on the client so it needs to (1) be
    > serializable and (2) be small.
    >
    > Karl
    >
    > --
    > http://www.openmymind.net/
    > http://www.fuelindustries.com/
    >
    >
    > "sloan" <> wrote in message
    > news:...
    > >
    > > The 3 main ways to cache objects are:
    > >
    > > Application
    > > Session
    > > Context
    > >
    > > http://msdn2.microsoft.com/en-us/library/system.web.ui.page.context.aspx
    > >
    > > Context gives you a "one time shot" at getting the values.
    > >
    > > It may not be exactly what you looking for, however, those are the main

    3,
    > > and Context is the closest one to your description.
    > >
    > >
    > > If you look at my blog:
    > >
    > > You can use my Session Object Wrapper, and my .Remove method.
    > >
    > > http://sholliday.spaces.msn.com/PersonalSpace.aspx 10/24/2005 entry
    > >
    > >
    > >
    > > "Prashanth" <> wrote in message
    > > news:...
    > >> Hi,
    > >> I want to cache an object whose scope in only within the page. The
    > >> cache should expire once the user leaves the page. How can I do it?
    > >> Regards,
    > >> Prashanth
    > >>

    > >
    > >

    >
    >
    sloan, Jun 20, 2006
    #4
  5. Prashanth

    Prashanth Guest

    Karl,
    I want the data to survive a post back but cannot use viewstate since
    the objects is not serializable.

    Karl Seguin [MVP] wrote:

    > Sloan:
    > You are missing the viewstate. I only mention it because it might be what's
    > wanted in this case. "scope of the page" isn't particularly clear though, so
    > it's hard to tell. Context is ideal for dealing with the start of page
    > processing (say init) to the end (say prerender). If you want the data to
    > survive a postback, you'll need to do something more persistant. ViewState
    > might work, but it's rendered on the client so it needs to (1) be
    > serializable and (2) be small.
    >
    > Karl
    >
    > --
    > http://www.openmymind.net/
    > http://www.fuelindustries.com/
    >
    >
    > "sloan" <> wrote in message
    > news:...
    > >
    > > The 3 main ways to cache objects are:
    > >
    > > Application
    > > Session
    > > Context
    > >
    > > http://msdn2.microsoft.com/en-us/library/system.web.ui.page.context.aspx
    > >
    > > Context gives you a "one time shot" at getting the values.
    > >
    > > It may not be exactly what you looking for, however, those are the main 3,
    > > and Context is the closest one to your description.
    > >
    > >
    > > If you look at my blog:
    > >
    > > You can use my Session Object Wrapper, and my .Remove method.
    > >
    > > http://sholliday.spaces.msn.com/PersonalSpace.aspx 10/24/2005 entry
    > >
    > >
    > >
    > > "Prashanth" <> wrote in message
    > > news:...
    > >> Hi,
    > >> I want to cache an object whose scope in only within the page. The
    > >> cache should expire once the user leaves the page. How can I do it?
    > >> Regards,
    > >> Prashanth
    > >>

    > >
    > >
    Prashanth, Jun 23, 2006
    #5
  6. Well, either make it serializable(which isn't always possible) or you'll
    need to persist it in memory. You are likely stuck using sessions.

    Karl

    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "Prashanth" <> wrote in message
    news:...
    > Karl,
    > I want the data to survive a post back but cannot use viewstate since
    > the objects is not serializable.
    >
    > Karl Seguin [MVP] wrote:
    >
    >> Sloan:
    >> You are missing the viewstate. I only mention it because it might be
    >> what's
    >> wanted in this case. "scope of the page" isn't particularly clear though,
    >> so
    >> it's hard to tell. Context is ideal for dealing with the start of page
    >> processing (say init) to the end (say prerender). If you want the data
    >> to
    >> survive a postback, you'll need to do something more persistant.
    >> ViewState
    >> might work, but it's rendered on the client so it needs to (1) be
    >> serializable and (2) be small.
    >>
    >> Karl
    >>
    >> --
    >> http://www.openmymind.net/
    >> http://www.fuelindustries.com/
    >>
    >>
    >> "sloan" <> wrote in message
    >> news:...
    >> >
    >> > The 3 main ways to cache objects are:
    >> >
    >> > Application
    >> > Session
    >> > Context
    >> >
    >> > http://msdn2.microsoft.com/en-us/library/system.web.ui.page.context.aspx
    >> >
    >> > Context gives you a "one time shot" at getting the values.
    >> >
    >> > It may not be exactly what you looking for, however, those are the main
    >> > 3,
    >> > and Context is the closest one to your description.
    >> >
    >> >
    >> > If you look at my blog:
    >> >
    >> > You can use my Session Object Wrapper, and my .Remove method.
    >> >
    >> > http://sholliday.spaces.msn.com/PersonalSpace.aspx 10/24/2005 entry
    >> >
    >> >
    >> >
    >> > "Prashanth" <> wrote in message
    >> > news:...
    >> >> Hi,
    >> >> I want to cache an object whose scope in only within the page. The
    >> >> cache should expire once the user leaves the page. How can I do it?
    >> >> Regards,
    >> >> Prashanth
    >> >>
    >> >
    >> >

    >
    Karl Seguin [MVP], Jun 23, 2006
    #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:
    558
    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,227
    vMike
    Jan 20, 2004
  3. =?Utf-8?B?b25l?=
    Replies:
    1
    Views:
    5,272
    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:
    464
    Sergey via DotNetMonster.com
    Nov 15, 2006
  5. John
    Replies:
    2
    Views:
    1,172
Loading...

Share This Page