Answer Posted / darshan
Basically cache is used to store frequently accessed data
into the memory, for faster retrieval.
Cache object is dictionary, it stores data in key=>value
pair combination. There are two ways to store the data into
the cache.
1. Cache.Add(key, value, dependance, absolute expiration,
sliding expiration, priority, onRemoveCallback);
2. Cache["key"] = value;
Note: If you are not working in web project, then you might
need to create instance of cache class, like following.
Cache che = new Cache();
che.Add(....);
che["key"] = value;
-----------------------------------------------------------------------
Example:
using System;
using System.Web.Caching;
namespace cacheExample
{
public class Example
{
public static void Main()
{
Cache ch = new Cache();
ch["name"] = "Anonymous";
console.WriteLine("Hello your name is: {0}",
ch["name"].ToString();
}
}
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Can we set master page as a start page?
Difference between using directive vs using statement?
What kind of data can be stored in viewstate?
What are the data controls available in asp.net?
Explain what are the advantages of asp.net mvc framework? : asp.net mvc
Explain the advantages of caching?
What are the different web pages?
How does a content page differ from a master page?
Explain asp.net page life cycle?
How to retrieve user name in case of Window Authentication?
What are asp.net web forms?
What is the difference between CC and BCC?
Explain the procedure to handle the process request using mhpm events fired? : asp.net mvc
Do I need to have the latest version of windows media player installed?
What are validator? Name the validation controls in asp.net?