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
What are the cookies types in asp.net?
5. What three Specific Job Positions do you target from Swatz Oils GROUP U.K?
From which base class all web forms are inherited?
Explain asp.net mvc request life cycle? : asp.net mvc
What are main return types supported in Web API?
What is the use of web.config and machine.config files?
What kind of programming language is ASP.NET?
What is the difference between equals() and == in c#?
Define web services in asp.net.
How do you declare static variable? What is its lifetime?
Can the validation occurs in server-side or client-side? If the validation occurs why should we do?
How you can add an event handler?
What is dynamic web page with example?
How should I destroy my objects in asp.net?
What is the biggest disadvantage of “Other Return Types” in Web API?