Cache object code - Caching pages and data

Q.  What code you will write for using the cache object?
- Published on 27 Jul 15

a.
// Storing the value.
Cache["name"]="CareerRide";
// Retrieving the value on any webpage within the application.
if (Cache["name"] != null)
Label1.Text= Cache["name"].ToString();
b.
// Storing the value.
Cache="CareerRide";
// Retrieving the value on any webpage within the application.
if (Cache != null)
Label1.Text= Cache.getStringValue;
c.
// Storing the value.
Cache["name"]="CareerRide";
// Retrieving the value on any webpage within the application.
if (Cache["name"] != null)
Label1.Text= Cache["name"].Text;
d. None of the above.

ANSWER:
// Storing the value.
Cache["name"]="CareerRide";
// Retrieving the value on any webpage within the application.
if (Cache["name"] != null)
Label1.Text= Cache["name"].ToString();
 

    Discussion

  • Raj Singh   -Posted on 24 Sep 15
    Cache object is a key, value pair collection. It is a flexible technique to store data for increasing performance.
    // Storing the value.
    Cache["name"]="CareerRide";
    // Retrieving the value on any webpage within the application.
    if (Cache["name"] != null)
    Label1.Text= Cache["name"].ToString();

    There is another way to insert the data into cache. Cache object has insert() method. By using Insert method, you can set cache expiration policy, Priority, Dependencies, etc.

➨ Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)
▲