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
How will you load dynamic assembly? How will create assesblies at run time?
In your ASP.NET 2.0 web application you want to display an image that is selected from a collection of images. What approach will you use to implementing this?
How can we Validate a Controls in ASP.NET page using JavaScript?
How to implement globalization and localization in the use interface in .net.
Which two new properties are added in asp.net 4.0 page class?
Explain the purpose of storyboard.targetproperty.
What is the difference between ldap and active directory?
Explain the significance of routing? : asp.net mvc
What is difference between session and cookies in asp net?
How do session tokens work?
What is the difference between the asp and asp.net?
What are the two properties that are common on every validation control?
How to include silver light .xap page into asp.net web application and what is the purpose of using silverlight application?
Is asp.net web forms dead?
How would you implement inheritance using c#?