|
|
|
start date: Wed, 15 Aug 2007 10:48:26 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
DanG
|
|
2
Göran Andersson
|
Caching question
..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
Date:Wed, 15 Aug 2007 10:48:26 -0700
Author:
|
Re: Caching question
DanG wrote:
> .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.
--
Gran Andersson
_____
http://www.guffa.com
Date:Wed, 15 Aug 2007 21:01:09 +0200
Author:
|
|
|