Caching question

D

DanG

..NET Framework 1.1.

Are Page.Cache, Page.Context.Cache and Context.Cache all the same? I
don't see enough In the MSDN to clarify it for me. The 1.1 Page class
has a Cache property, but no Context property (as it does in 2.0). My
search for a 1.1 Context class keeps refering to the 2.0
Page.Context. So, I'm confused.

I'm working on an application written by another developer who isn't
here anymore. He used Context.Cache, and it might be causing a
problem.

We have a screen that accumulates objects in Context Cache, and later
reads the cache and writes this data to the database. Apparently, we
had two users on different machines, both submitting at the same time,
since the timestamps on the DB records are milliseconds apart. One
user got all records, and the other didn't get any. My guess is that
they were sharing Context.Cache, and the server read whatever was in
cache and gave it all to one of the users.

Could Context.Cache do this? Is Page.Cache different/better for this
scenario? Or is Session Cache a better choice?

Thanks
Dan
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

DanG said:
.NET Framework 1.1.

Are Page.Cache, Page.Context.Cache and Context.Cache all the same?

Page is a reference to the current page, so as long as you are in the
page, it's superflous. Page.Cache is the same as Cache (and the same as
Page.Page.Page.Page.Page.Cache).

Cache and Context.Cache is the same.

Page.Context.Cache is not available. As Context is a protected property,
you can't access it as Page.Context, only as Context (or this.Context).

The documentation says that the Cache property in the HttpContext class
gets the cache object for the current request. Having a cache object
that only lives for the duration of a request would however be totally
pointless. It actually gets the cache object for the web application,
just as the Cache property in the Page class.
I
don't see enough In the MSDN to clarify it for me. The 1.1 Page class
has a Cache property, but no Context property (as it does in 2.0). My
search for a 1.1 Context class keeps refering to the 2.0
Page.Context. So, I'm confused.

I'm working on an application written by another developer who isn't
here anymore. He used Context.Cache, and it might be causing a
problem.

We have a screen that accumulates objects in Context Cache, and later
reads the cache and writes this data to the database. Apparently, we
had two users on different machines, both submitting at the same time,
since the timestamps on the DB records are milliseconds apart. One
user got all records, and the other didn't get any. My guess is that
they were sharing Context.Cache, and the server read whatever was in
cache and gave it all to one of the users.

Could Context.Cache do this? Is Page.Cache different/better for this
scenario? Or is Session Cache a better choice?

Caching has application scope, so it's shared by all users. If you want
to store user specific data, you should not cache it, you should use the
Session object.
 

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

Similar Threads

Caching App Data 1
Directory Caching, suggestions and comments? 0
Caching .. 4
Caching architecture question. 1
Data caching question 3
Custom control caching 0
Caching Questions 0
Question about my projects 3

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,061
Latest member
KetonaraKeto

Latest Threads

Top