473,408 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Cache an object

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

Jun 20 '06 #1
5 1211

The 3 main ways to cache objects are:

Application
Session
Context

http://msdn2.microsoft.com/en-us/lib...e.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" <pr****@gmail.com> wrote in message
news:11**********************@r2g2000cwb.googlegro ups.com...
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

Jun 20 '06 #2
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" <sl***@ipass.net> wrote in message
news:e2**************@TK2MSFTNGP02.phx.gbl...

The 3 main ways to cache objects are:

Application
Session
Context

http://msdn2.microsoft.com/en-us/lib...e.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" <pr****@gmail.com> wrote in message
news:11**********************@r2g2000cwb.googlegro ups.com...
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


Jun 20 '06 #3
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:e3**************@TK2MSFTNGP02.phx.gbl...
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" <sl***@ipass.net> wrote in message
news:e2**************@TK2MSFTNGP02.phx.gbl...

The 3 main ways to cache objects are:

Application
Session
Context

http://msdn2.microsoft.com/en-us/lib...e.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" <pr****@gmail.com> wrote in message
news:11**********************@r2g2000cwb.googlegro ups.com...
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



Jun 20 '06 #4
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" <sl***@ipass.net> wrote in message
news:e2**************@TK2MSFTNGP02.phx.gbl...

The 3 main ways to cache objects are:

Application
Session
Context

http://msdn2.microsoft.com/en-us/lib...e.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" <pr****@gmail.com> wrote in message
news:11**********************@r2g2000cwb.googlegro ups.com...
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



Jun 23 '06 #5
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" <pr****@gmail.com> wrote in message
news:11**********************@b68g2000cwa.googlegr oups.com...
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" <sl***@ipass.net> wrote in message
news:e2**************@TK2MSFTNGP02.phx.gbl...
>
> The 3 main ways to cache objects are:
>
> Application
> Session
> Context
>
> http://msdn2.microsoft.com/en-us/lib...e.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" <pr****@gmail.com> wrote in message
> news:11**********************@r2g2000cwb.googlegro ups.com...
>> 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
>>
>
>

Jun 23 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim | last post by:
Hi, I have a few questions regarding the cache object: Does the cache object exist through postbacks? The cache object only exists for the current request, right? Is there a way to cache...
1
by: Glenn | last post by:
Hi, I have a config XML file that I am using from the application cache. I have configured the entry with a remove callback to re-populate cache automatically when the XML file changes. All is...
4
by: NWx | last post by:
Hi, I' trying to implement a callback method when a cache object expires I want to do this to automatically logout user after a timeout (for demo purposes) My thought is, when user logon,...
9
by: Joe Fallon | last post by:
If I add an instance of an object to the Cache what is returned when I request the item from the cache? Is it a clone of the object or is it a reference to the object? I want to know because I...
13
by: Fernando Chilvarguer | last post by:
Hi, I'm retriving data from a database and storing it on the Cache Object using the following code: HttpContext.Current.Cache.Insert( cacheItemKey, contentDS, //THE DATASET WITH MY DATA...
1
by: Brian Linden | last post by:
I cache a ton of stuff, and my application works great....but...... When I am stress testing it I'll get the "Object reference not set to an instance of an object" every once in a while... It...
2
by: Ryan Ternier | last post by:
I'm playing around with Cache and Viewstate. I've made a small little example that reminds me of grade 12: if(!IsPostBack) { ArrayList alTest = new ArrayList(); alTest.Add("This is from...
6
by: Charts | last post by:
I used HttpContext.Current.Cache To cache data from database. The code is like that. public static DataView GetCategories() { if ( HttpContext.Current.Cache == null ) {...
1
by: William Sullivan | last post by:
I'm trying to nail down some issues with the cache in my application. Currently, I have an object that stands between my business logic and database logic called CacheLogic (cute, no?). ...
1
by: Jose Fernandez | last post by:
Hello First of all, sorry for my bad english ;) I have a USER class that i create to every user that enters the website (not neccesarily logged in). At the same time i insert it into a the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.