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
LowCache items with this priority level are the most likely to be deleted from the cache as the server frees system memory.
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.
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.
AboveNormalCache items with this priority level are less likely to be deleted as the server frees system memory than those assigned a Normal priority.
HighCache items with this priority level are the least likely to be deleted from the cache as the server frees system memory.
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.
DefaultThe default value for a cached item's priority is Normal.

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, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Community Additions

ADD
Show:
© 2014 Microsoft