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 is session and application variable in asp net?
Explain form level validation and field level validation?
What is asp.net caching?
Securitywise What are the Enhancements in 2.0?
Explain State management in asp.net
What is meant by server side scripting?
What is the use of web.config and machine.config files?
What are the differences between code behind and code inline?
Describe the difference between inline and code behind - which is best in a?
How you can access the values from the Repeater control in ASP.NET?
What is the use of execute non query in asp.net?
What permissions do asp.net applications posses by default?
List of words of preprocessor in .net?
What is the difference between “Web.config” and “Machine.Config”?
How can we use Web API with ASP.NET Web Form?