467,925 Members | 1,869 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,925 developers. It's quick & easy.

How to implement cache in WinForms application

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.

Jun 11 '07 #1
  • viewed: 15879
Share:
8 Replies
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


"Andrus" wrote:
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.

Jun 11 '07 #2
On Jun 11, 4:47 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
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

"Andrus" wrote:
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.- Hide quoted text -

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

Jun 11 '07 #3
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.

Jun 11 '07 #4
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.

Jun 11 '07 #5
On Jun 11, 9:25 pm, "Andrus" <kobrule...@hot.eewrote:
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.
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?

Jun 11 '07 #6
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


"Andrus" wrote:
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.

Jun 11 '07 #7
On Jun 11, 9:25 pm, "Andrus" <kobrule...@hot.eewrote:
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.

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.

Jun 11 '07 #8
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.

Jun 11 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Invalidlastname | last post: by
2 posts views Thread by Harry Simpson | last post: by
1 post views Thread by Vinit | last post: by
4 posts views Thread by 3Cooks | last post: by
3 posts views Thread by moondaddy | last post: by
23 posts views Thread by raylopez99 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.