Export (0) Print
Expand All

CacheItemPriority Enumeration

Specifies the relative priority of items stored in the Cache object.

Namespace:  System.Web.Caching
Assembly:  System.Web (in System.Web.dll)

public enum CacheItemPriority

Member nameDescription
AboveNormalCache items with this priority level are less likely to be deleted as the server frees system memory than those assigned a Normal priority.
BelowNormalCache items with this priority level are more likely to be deleted from the cache as the server frees system memory than items assigned a Normal priority.
DefaultThe default value for a cached item's priority is Normal.
HighCache items with this priority level are the least likely to be deleted from the cache as the server frees system memory.
LowCache items with this priority level are the most likely to be deleted from the cache as the server frees system memory.
NormalCache items with this priority level are likely to be deleted from the cache as the server frees system memory only after those items with Low or BelowNormal priority. This is the default.
NotRemovableThe cache items with this priority level will not be automatically deleted from the cache as the server frees system memory. However, items with this priority level are removed along with other items according to the item's absolute or sliding expiration time.

When the Web server hosting an ASP.NET application runs low on memory, the Cache object selectively purges items to free system memory. When an item is added to the cache, you can assign it a relative priority compared to the other items stored in the cache. Items to which you assign higher priority values are less likely to be deleted from the cache when the server is processing a large number of requests, whereas items to which you assign lower priority values are more likely to be deleted. The default is Normal.

NoteNote

Items can always be removed from the cache programmatically, regardless of their cache priority.

The following code example uses the Insert method to add an item to the Cache object with its priority parameter set to High.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="c#" runat="server">
    public void Page_Load(Object sender, EventArgs e) {
        String connectionString;
        connectionString = "Data Source=localhost;Integrated Security=SSPI";
        Cache.Insert("DSN", connectionString, null, DateTime.Now.AddMinutes(2), TimeSpan.Zero, CacheItemPriority.High, null);
    }
</script>

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft