Caching frequently accessed data is required/desirable in Winforms Smart Client applications. Reading data from cache is often faster than hitting your data providers/web services.
Here are a couple of options with examples
- Enterprise library's caching application block is a good choice.
- Also, System.Web.Caching.Cache can be used with Winforms, just get a static instance.
See the example below.
With Entlib
using Microsoft.Practices.EnterpriseLibrary.Caching;
//Later
CacheManager cache= CacheFactory.GetCacheManager();
cache.Add("dataKey", "Yourdata")
With .NET built-in cache - This'll work for your Winform app also.
using System.Web.Caching;
using System.Web;
public sealed class CacheProvider
{
private CacheProvider(){};
public static GetInstance()
{
return HttpRuntime.Cache;
}
}