How to implement cache in WinForms application

A

Andrus

I'm creating C# WinForms client-server database application.

This application reads data from PostgreSQL server using npgsql Dataadapter
and DataReader classes and stores data mostly in Datasets and sometimes in
business object properties.

A lot of lookup tables (payment terms, currency list etc) are static.
Currently application reads them from server when new window is opened over
TCP connection
This makes application slow.

How to cache data in client side ?

Where to find caching module for .NET application ?

It it reasonable to use .NET 2 Web Cache object for this ?
MS Web Cache object doc says that it is designed only for ASP .NET
application.
Is it reasonable to use it in WinForms application or are there better
caching object available?

I cannot use MS Caching application block since my application needs to run
in
Linux also.

Andrus.
 
G

Guest

You could use the Enterprise Library Caching module. Or, for a simple cache,
use the AppDomain cache:

AppDomain.CurrentDomain.SetData("key", value);
DataSet ds = (DataSet)AppDomain.CurrentDomain.GetData("keyname");

Peter
 
A

Aneesh Pulukkul[MCSD.Net]

You could use the Enterprise Library Caching module. Or, for a simple cache,
use the AppDomain cache:

AppDomain.CurrentDomain.SetData("key", value);
DataSet ds = (DataSet)AppDomain.CurrentDomain.GetData("keyname");

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net












- Show quoted text -

Where exactly it would be stored, I mean inside app domain, does it
maintain a section for SetData() data?
 
A

Andrus

You could use the Enterprise Library Caching module. Or, for a simple
cache,
use the AppDomain cache:

AppDomain.CurrentDomain.SetData("key", value);
DataSet ds = (DataSet)AppDomain.CurrentDomain.GetData("keyname");

Peter,

thank you.

I looked into MSDN but doc about those methods is terse.

Will the dataset persist if I exit and re-run my application ?
Are they stored in isolated storage ?

How I can invalidate objects in cache? I think I need to implement command
like "Refresh" which causes to re-load all data.

Andrus.
 
A

Andrus

Where exactly it would be stored, I mean inside app domain, does it
maintain a section for SetData() data?

I think datasets should be stored in memory and maybe in isolated storage
also.

I did'nt understand your question about SetData() section.

I need also some method to clear the cache (invalidate all stored data).

Andrus.
 
A

Aneesh Pulukkul[MCSD.Net]

I think datasets should be stored in memory and maybe in isolated storage
also.

I did'nt understand your question about SetData() section.

I need also some method to clear the cache (invalidate all stored data).

Andrus.

I was asking abou the storage - if we use the SetData() method, where
would the data be placed. A hashtable in the app domain space?
 
G

Guest

No, because when you quit your app you're tearing down the AppDomain it was
loaded into. However, the idea of a cache is that when your app starts, you
get the data one time and cache it, so that should not be a problem.
If you want cache invalidation and all the "fancy stuff", take a look at the
latest (3.1) version of the Enterprise Library.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
 
A

Andrus

I was asking abou the storage - if we use the SetData() method, where
would the data be placed. A hashtable in the app domain space?

As I understand from Peter and your replies, SetData() simply holds objects
in memory hash table.

I have no idea why SetData() and GetData() methods are present
in AppDomain class at all: it should be trivial to create hash table in
application for this.

Andrus.
 
A

Andrus

No, because when you quit your app you're tearing down the AppDomain it
was
loaded into. However, the idea of a cache is that when your app starts,
you
get the data one time and cache it, so that should not be a problem.

Why SetData() and GetData() methods exist in AppDomain ?
It should be trivial to create hash table which holds object type of object
and use it insted using those methods !?

Why those methods exist in .NET ?
If you want cache invalidation and all the "fancy stuff", take a look at
the
latest (3.1) version of the Enterprise Library.

Enterprise Library license prohibits its usage in non-Windows environment.

If I need that my application can run in Linux with MONO , how I can use
Enterprise Library ?

Andrus.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top