3

My wpf client is loading a lot of standing data at startup from the server. So, I want to implement a caching strategy at client side.

I know about the new System.Runtime.Caching namespace in the .NET framework 4. Unfortunately, there is only a memory caching. I don't want to load the huge amount of data at each startup of the client. So I'm searching for a persistent client caching.

What do you think about it?

Another idea was I use an OODB (like db4o or VelocityDB) for client caching. Is this a bad idea? I haven't any experience in client caching.

Thanks for your answers and suggestions.

Kind regards, pro

bitsmuggler
  • 1,689
  • 2
  • 17
  • 30

1 Answers1

2

How you store the data on the client side doesn't matter very much. I'd look into IsolatedStorage for your purposes, though. What might be more difficult is to tell when the cache turns stale. This is actually what System.Runtime.Caching is good at. Does the server data change at all, or only after a new release of the application? If the data changes only after a new release, you might want to include it as resources into the application setup. If not, you'd have to have some timeout or signal which tells the client that it is time to check for changed data on the server. Have you already considered lazy loading of the data? That way, the delay would probably not occur all at application startup and would be less noticable, and probably you wouldn't even have to load the complete data into the client.

Regarding Timeouts: in our application, we have a fixed timeout which is set to each reference list when it is first loaded, and every time it is requested from the cache, that timeout is checked. If it has expired, the cache is transparently refreshed before the list is returned. This is a tradeoff, because the data on the client side could be stale for some time. We accept this, because it isn't critical in our case, and that way every list is responsible for itself and we don't need a central registry keeping track of each list's state in order to set the timeout from outside.

hbarck
  • 2,934
  • 13
  • 16
  • @hbark: thanks for your answer. The isolated storage is a good idea. The standing data of the application is independent of a specific release. Regarding to the lazy loading, I assume that it makes the wpf ui slow (e.g. I open a combobox and the client does a wcf call for loading the standing data - do you know what I mean?). For the change tracking of the cached data, I have the idea, that I have a timestamp for each standing data table which indicates if there is a change. What do you think about this idea? – bitsmuggler Oct 03 '12 at 08:06
  • Well, lazy loading just means the data gets loaded when it is needed and cached afterwards. Probably that would mean the delay would occur the first time the form which contains the ComboBox is shown, and wouldn't occur if the form is revisited later. With regard to timeouts: in our application, we have a fixed timeout which is set to each reference list when it is first loaded, and every time it is requested from the cache, that timeout is checked. If it has expired, the cache is transparently refreshed before the list is returned. – hbarck Oct 03 '12 at 08:21