Re: Can I store a C# Class Instance to the Server Cache?



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




.



Relevant Pages

  • Re: Can I store a C# Class Instance to the Server Cache?
    ... Thanks for your response. ... public string SID; ... I know this is 'working' since I'm able to retrieve this from the cache on ... anything explicitly to serialize this into the cache? ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Can I store a C# Class Instance to the Server Cache?
    ... mean that I need to serialize this explicitly into the Cache, ... public string SID; ... I know this is 'working' since I'm able to retrieve this from the cache on ... store VB6 class instances on the server. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Unable to Serialize
    ... I needed to make the RemoteUserDataBean Serializable (as well as the ... public class RemoteUserServiceService: ... public string employeeId; ... you posted nothing to serialize. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Adding Attributes (or equivalent effect) Without Touching Original Source Code
    ... An important server-side task is to serialize server-side objects to JSON, ... public Person(string firstName, string middleName, string lastName) ... public string MiddleName ... I do in fact have the source code of the classes that have been part of this ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: XmlSerializer would not serialize properties in the class derived from List
    ... custome property in a custom collection class by "design". ... public string ID ... when I use XmlSerializer to serialize the object. ...
    (microsoft.public.dotnet.xml)