Hi,
I am looking to cache a class in a .NET client/server application on the
client end. The server holds an instance of the class which is required on
the client at various points. Currently I have a cached version of the class
in a local member variable on the client. Updates to the data are not
frequent yet client access to the data is. The current cache is very basic;
the first time the class is requested it retrieves it from the server,
subsequent calls use the local member, and any update to the data on the
server forces the client to clear its local member so it get refreshed when
next requested.
My class has around 35 private members with public readonly or read/write
properties. Most properties are primitive (either strings or Booleans),
there are a few simple collections (dictionary string, integer), a few single
properties of a custom class type (class contains a few strings, guids, etc),
and a few lists or dictionaries using custom classes (generic.dictionary(of
guid, generic.dictionary(of guid, ivariable))). Nothing too complex.
Caching the object on the client still seems to present a performance impact
when accessing a property on the object. Even though it is cached locally it
seems to be making a trip back to the server as anything could by within the
Get of one of the properties.
How can I truly cache the object? I started reading up about the Microsoft
Caching Application Block but feel this could be a bit overkill. Would the
best solution be to create another custom class (held on the client) that
contains its own local members and exposes public functions or properties to
access the members? Or could I create some sort of generic collection of
cached members, keyed by the name of the property, and write a wrapper class
to maintain and access this list?
Regards, Carl Gilbert
Mufaka - 06 Mar 2008 17:02 GMT
> Hi,
>
[quoted text clipped - 29 lines]
>
> Regards, Carl Gilbert
I've used System.Web.HttpRuntime.Cache in windows services and desktop
applications without a problem.
Roy Lawson - 29 Mar 2008 15:33 GMT
One solution is to create a common interface that both classes implement.
That is probably the best solution in this case.
So yes, you would create two different classes on the client/server but both
classes would implement the same interface. You can put that interface in
common code that both projects reference.
Hope that helps.