Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Chart.SaveToCache Method

Saves a chart in the system cache.

Namespace:  System.Web.Helpers
Assembly:  System.Web.Helpers (in System.Web.Helpers.dll)
public string SaveToCache(
	string key,
	int minutesToCache,
	bool slidingExpiration
)

Parameters

key
Type: System.String
The ID of the chart in the cache.
minutesToCache
Type: System.Int32
The number of minutes to keep the chart image in the cache. The default is 20.
slidingExpiration
Type: System.Boolean
true to indicate that the chart cache item's expiration is reset each time the item is accessed, or false to indicate that the expiration is based on an absolute interval since the time that the item was added to the cache. The default is true.

Return Value

Type: System.String
The ID of the cache item that contains the chart.

The following example shows how to save a chart to cache using the SaveToCache method.


@{ 
    var chartKey = Request["key"]; 
    if (chartKey != null) { 
        var cachedChart = Chart.GetFromCache(key: chartKey); 
        if (cachedChart == null) { 
            cachedChart = new Chart(600, 400); 
            cachedChart.AddTitle("Cached Chart -- Cached at " + DateTime.Now); 
            cachedChart.AddSeries( 
               name: "Employee", 
               axisLabel: "Name", 
               xValue: new[] { "Peter", "Andrew", "Julie", "Mary", "Dave" }, 
               yValues: new[] { "2", "6", "4", "5", "3" }); 
            cachedChart.SaveToCache(key: chartKey,  
               minutesToCache: 2,  
               slidingExpiration: false); 
        } 
        Chart.WriteFromCache(chartKey); 
    } 
}


  • Medium trust for the immediate caller. This member can be used by partially trusted code.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.