|
|
|
date: Thu, 6 Mar 2008 07:34:00 -0800,
group: microsoft.public.dotnet.distributed_apps
back
Caching an object client side
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
date: Thu, 6 Mar 2008 07:34:00 -0800
author: Carl Gilbert
Re: Caching an object client side
Carl Gilbert wrote:
> 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
I've used System.Web.HttpRuntime.Cache in windows services and desktop
applications without a problem.
date: Thu, 06 Mar 2008 09:02:25 -0800
author: Mufaka
|
|