Re: Can I store a C# Class Instance to the Server Cache?
- From: "Joseph Geretz" <jgeretz@xxxxxxxxxx>
- Date: Wed, 14 Feb 2007 19:00:34 -0500
Thanks John,
Clearly, the ASP.NET Cache object doesn't need anything more than your
class provides
I know this works, but will I run into any threading problems? In other
words, let's say the user logs in with an instance of the ASMX page
executing on thread 345. The SessionCache class instance will be created on
thread 345 and a reference to that class instance will be stuffed into the
Server Cache. Let's say the next transaction for this user's session is
served up by an ASMX page executing on thread 987. Will access to the
SessionCache class instance involve a thread context switch from 987 to 345?
This is the sort of trap which looks like it's working initially, but as
usage scales up, this sort of problem will start to manifest itself in a big
way. (Forgive me for stressing the point, but a lot VB6 developers were
burned badly by saving class instances on the Server and I want to make sure
that .NET class instances aren't succeptible to the same type of thread
affinity problems.)
Thanks!
- Joseph Geretz -
"John Saunders" <john.saunders at trizetto.com> wrote in message
news:OO34RjIUHHA.4404@xxxxxxxxxxxxxxxxxxxxxxx
"Joseph Geretz" <jgeretz@xxxxxxxxxx> wrote in message
news:%23Rre6xHUHHA.528@xxxxxxxxxxxxxxxxxxxxxxx
Hi John,
Thanks for your response. I'm not sure what you mean by serializable. Do
you mean that I need to serialize this explicitly into the Cache, or that
the Framework will take care of the serialization for me if the class is
serializable?
Here is that class which I am caching.
internal class SessionCache
{
public string SID;
public string UID;
public string PWD;
public DataTable Profile;
}
I know this is 'working' since I'm able to retrieve this from the cache
on successive Web Method requests. Is this actually being serialized into
the cache for me 'under the hood'? Does it need to be? Do I need to do
anything explicitly to serialize this into the cache?
Joseph, I'm sorry, I wasn't thinking clearly. I was thinking about
ViewState, which _does_ require instances to be serializable. Clearly, the
ASP.NET Cache object doesn't need anything more than your class provides.
John
.
- Follow-Ups:
- Re: Can I store a C# Class Instance to the Server Cache?
- From: John Saunders
- Re: Can I store a C# Class Instance to the Server Cache?
- References:
- Can I store a C# Class Instance to the Server Cache?
- From: Joseph Geretz
- Re: Can I store a C# Class Instance to the Server Cache?
- From: John Saunders
- Re: Can I store a C# Class Instance to the Server Cache?
- From: Joseph Geretz
- Re: Can I store a C# Class Instance to the Server Cache?
- From: John Saunders
- Can I store a C# Class Instance to the Server Cache?
- Prev by Date: Re: Implementing a common SOAP Header across multiple Web Service Pages
- Next by Date: Re: Implementing a common SOAP Header across multiple Web Service Pages
- Previous by thread: Re: Can I store a C# Class Instance to the Server Cache?
- Next by thread: Re: Can I store a C# Class Instance to the Server Cache?
- Index(es):
Relevant Pages
|