Caching data in asp.net is very easy. So I just want to know how could I cache data in win application.
Suppose that I want to fetch & cache data from employee table and when ever any records will be inserted or updated in employee table then a event will fire in my form and from there I will reload those data from employee table again and cache it. It is very easy to implement in asp.net apps but how to implement this concept in win application. I don't want to use timer. please help me with concept ?
Caching is a separate memory, yes, and it has it's own addresses, but when the CPU caches memory lines from RAM, it keeps a record of what RAM-addresses the memory was on, and keeps a map between RAM-address and cache-address. From the point of view of your program, the address is the same.
Caching is a method of using main memory or RAM to efficiently manage frequently accessed data. Aside from being stored in RAM, data in the cache can also be used in correlation with a software component.
Caching: What, Why, and Where Caching is a technique used to manage frequently accessed data in-memory. The method facilitates access to data while also reducing the workload on the main data stores. Not only can caching enhance performance; it can also improve the scalability and availability of an application.
If you can target .NET 4 then you should take a look at the System.Runtime.Caching
namespace, and the MemoryCache
class in particular:
The
MemoryCache
class is similar to the ASP.NETCache
class. TheMemoryCache
class has many properties and methods for accessing the cache that will be familiar to you if you have used the ASP.NETCache
class. The main differences between theCache
andMemoryCache
classes are that theMemoryCache
class has been changed to make it usable by .NET Framework applications that are not ASP.NET applications. For example, theMemoryCache
class has no dependencies on theSystem.Web
assembly. Another difference is that you can create multiple instances of theMemoryCache
class for use in the same application and in the sameAppDomain
instance.
This would be easy if you use Microsoft application block, you may want to explore more Caching Application Block http://msdn.microsoft.com/en-us/library/ff647280.aspx
You may want to look into specifically - Memcached with Windows and .NET
Memcache is a popular solution. There are some .NET ports:
Is there a port of memcache to .Net?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With