संपादित करें

इसके माध्यम से साझा किया गया


CacheItemPriority Enum

Definition

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

public enum class CacheItemPriority
public enum CacheItemPriority
type CacheItemPriority = 
Public Enum CacheItemPriority
Inheritance
CacheItemPriority

Fields

Name Value Description
Low 1

Cache items with this priority level are the most likely to be deleted from the cache as the server frees system memory.

BelowNormal 2

Cache 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.

Default 3

The default value for a cached item's priority is Normal.

Normal 3

Cache 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.

AboveNormal 4

Cache items with this priority level are less likely to be deleted as the server frees system memory than those assigned a Normal priority.

High 5

Cache items with this priority level are the least likely to be deleted from the cache as the server frees system memory.

NotRemovable 6

The 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.

Examples

The following example uses the Cache.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>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    Public Sub Page_Load(sender As Object, e As EventArgs)
        Dim connectionString As String
        connectionString = "Data Source=localhost;Integrated Security=SSPI"
        Cache.Insert("DSN", connectionString, Nothing, DateTime.Now.AddMinutes(2), TimeSpan.Zero, CacheItemPriority.High, Nothing)
    End Sub
</script>

Remarks

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.

Note

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

Applies to

See also