What is Cache ? If we use Cache Performace is improvement high?

Posted by Raja123 under Interview Questions on 9/6/2010 | Points: 10 | Views : 1490 | Status : [Member] | Replies : 1
Can you tell anyone, if we use cache in our application the performance will increase or decrease? Please tell the scenario when to go for cache. what are the type we need use?


Posted by: T.saravanan on: 9/17/2010 [Member] [MVP] Silver | Points: 25

Hi Raja123,

Actually Cache is not used for Performance but it avoid time delay of data fetching.
To get a data from database and store into cache means easily to get the data without go to server.

Here i am using web services for Cache.


using System.Web.Caching;

//Declare a Cache Object
Cache csEmpData;
string sData="Emp Details";

public DataTable GetDetails()
if(csEmpData[sData] == null)
// Data Fetching Method from DataBase
DataTable dt = new DataTable(); // Here dt is Output Data
csEmpData.Insert(sData, (object)dt, null ,DateTime.Now.AddMinuutes(30), TimeSpan.Zero, CacheItemPriority.Default, null);
return (DataTable) (csEmpData[sData]);
return (DataTable) (csEmpData[sData]);

In this method i had set a time limit for cache is '30' minutes.So if i fetch the data with in 30 minutes, the data come from Cache object else its goes to database and then fetch the data.
Here i am give just basic idea only.
Refer this link its also helpful to you.

In my suggestion read more no.of articles.

Cheers :)


Raja123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response