Sunday, March 27, 2011

System.Runtime.Caching Namespace for Caching-II

In this Blog Post we are going to see how we can use this API in .NET Applications.

image

Here I am going create my own CacheLib class with the following   Add, Get, Remove methods as shown above.

First Let me create a C# class file called  CacheLib.cs  in which  I am going to implement all the CURD methods for the Cache object. to do let us create ObjectCache Cache = MemoryCache.Default . (Memory Cache) Then we Add Get, Add, Remove Methods.

Add any object to Cache:

Here  I am created the Generic Add method.

image

Get or Retrieve Cached Item from Cache Object: Generic get method

image

Remove or Delete from Cache:

image

User Defined class to store in Cache.

image

the following Code snippet shows how to add and retrieve data from Cache object .

image

Nandri(Thanks)

Sreenivasa Ragavan

No comments: