CacheSection 클래스

정의

ASP.NET 애플리케이션의 전역 캐시 설정을 구성합니다. 이 클래스는 상속될 수 없습니다.

public ref class CacheSection sealed : System::Configuration::ConfigurationSection
public sealed class CacheSection : System.Configuration.ConfigurationSection
type CacheSection = class
    inherit ConfigurationSection
Public NotInheritable Class CacheSection
Inherits ConfigurationSection
상속

예제

다음 코드 예제에서는 페이지 및 관련된 코드 파일에 사용 되는 액세스를 CacheSection 특성 섹션입니다.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReadWriteCache.aspx.cs" Inherits="ReadWriteCache" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Read Write Application Cache</title>
</head>
<body>
    <form id="form1" runat="server">
        <h2>Read Write Application Cache</h2>

        <asp:Label ID="Label1" Text="[Application Cache goes here.]" runat="server"></asp:Label>
        
        <hr />

        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Write Cache" />    
        <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Read Cache" />
    </form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ReadWriteCache.aspx.vb" Inherits="ReadWriteCache" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Read Write Application Cache</title>
</head>
<body>
    <form id="form1" runat="server">
        <h2>Read Write Application Cache</h2>

        <asp:Label ID="Label1" Text="[Application Cache goes here.]" runat="server"></asp:Label>
        
        <hr />

        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Write Cache" />    
        <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Read Cache" />
    </form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ReadWriteCache : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Label1.Text = "Application Cache goes here.";
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        // Get the application configuration file.
        System.Configuration.Configuration config =
          System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");

        System.Web.Configuration.CacheSection cacheSection =
            (System.Web.Configuration.CacheSection)config.GetSection(
                "system.web/caching/cache");

        // Increase the PrivateBytesLimit property to 0.
        cacheSection.PrivateBytesLimit = 
            cacheSection.PrivateBytesLimit + 10;

        // Increase memory limit.
        cacheSection.PercentagePhysicalMemoryUsedLimit = 
            cacheSection.PercentagePhysicalMemoryUsedLimit + 1;

        // Increase poll time.
        cacheSection.PrivateBytesPollTime =
            cacheSection.PrivateBytesPollTime + TimeSpan.FromMinutes(1);

        // Enable or disable memory collection.
        cacheSection.DisableMemoryCollection = 
                !cacheSection.DisableMemoryCollection;

        // Enable or disable cache expiration.
        cacheSection.DisableExpiration =
            !cacheSection.DisableExpiration;

        // Save the configuration file.
        config.Save(System.Configuration.ConfigurationSaveMode.Modified);      
    }

    protected void Button2_Click(object sender, EventArgs e)
    {

        // Get the application configuration file.
        System.Configuration.Configuration config =
          System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");

        System.Web.Configuration.CacheSection cacheSection =
            (System.Web.Configuration.CacheSection)config.GetSection(
                "system.web/caching/cache");

        // Read the cache section.
        System.Text.StringBuilder buffer = new System.Text.StringBuilder();

        string currentFile = cacheSection.CurrentConfiguration.FilePath;
        bool dExpiration = cacheSection.DisableExpiration;
        bool dMemCollection = cacheSection.DisableMemoryCollection;
        TimeSpan pollTime = cacheSection.PrivateBytesPollTime;
        int phMemUse = cacheSection.PercentagePhysicalMemoryUsedLimit;
        long pvBytesLimit = cacheSection.PrivateBytesLimit;

        string cacheEntry = String.Format("File: {0} <br/>", currentFile);
        buffer.Append(cacheEntry);
        cacheEntry = String.Format("Expiration Disabled: {0} <br/>", dExpiration);
        buffer.Append(cacheEntry);
        cacheEntry = String.Format("Memory Collection Disabled: {0} <br/>", dMemCollection);
        buffer.Append(cacheEntry);
        cacheEntry = String.Format("Poll Time: {0} <br/>", pollTime.ToString());
        buffer.Append(cacheEntry);
        cacheEntry = String.Format("Memory Limit: {0} <br/>", phMemUse.ToString());
        buffer.Append(cacheEntry);
        cacheEntry = String.Format("Bytes Limit: {0} <br/>", pvBytesLimit.ToString());
        buffer.Append(cacheEntry);

        Label1.Text = buffer.ToString();
    }
}
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Partial Public Class ReadWriteCache
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not IsPostBack Then
            Label1.Text = "Application Cache goes here."
        End If

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Get the application configuration file.
        Dim config As System.Configuration.Configuration =
            System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/")


        Dim cacheSection As System.Web.Configuration.CacheSection =
            CType(config.GetSection("system.web/caching/cache"), System.Web.Configuration.CacheSection)

        ' Increase the PrivateBytesLimit property to 0.
        cacheSection.PrivateBytesLimit = cacheSection.PrivateBytesLimit + 10


        ' Increase memory limit.
        cacheSection.PercentagePhysicalMemoryUsedLimit =
            cacheSection.PercentagePhysicalMemoryUsedLimit + 1

        ' Increase poll time.
        cacheSection.PrivateBytesPollTime =
            cacheSection.PrivateBytesPollTime + TimeSpan.FromMinutes(1)


        ' Enable or disable memory collection.
        cacheSection.DisableMemoryCollection =
            Not cacheSection.DisableMemoryCollection

        ' Enable or disable cache expiration.
        cacheSection.DisableExpiration =
            Not cacheSection.DisableExpiration

        ' Save the configuration file.
        config.Save(System.Configuration.ConfigurationSaveMode.Modified)

    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)

        ' Get the application configuration file.
        Dim config As System.Configuration.Configuration =
            System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/")


        Dim cacheSection As System.Web.Configuration.CacheSection =
            CType(config.GetSection("system.web/caching/cache"), System.Web.Configuration.CacheSection)

        ' Read the cache section.
        Dim buffer As New System.Text.StringBuilder()

        Dim currentFile As String = cacheSection.CurrentConfiguration.FilePath
        Dim dExpiration As Boolean = cacheSection.DisableExpiration
        Dim dMemCollection As Boolean = cacheSection.DisableMemoryCollection
        Dim pollTime As TimeSpan = cacheSection.PrivateBytesPollTime
        Dim phMemUse As Integer = cacheSection.PercentagePhysicalMemoryUsedLimit
        Dim pvBytesLimit As Long = cacheSection.PrivateBytesLimit

        Dim cacheEntry As String = String.Format("File: {0} <br/>", currentFile)
        buffer.Append(cacheEntry)
        cacheEntry = String.Format("Expiration Disabled: {0} <br/>", dExpiration)
        buffer.Append(cacheEntry)
        cacheEntry = String.Format("Memory Collection Disabled: {0} <br/>", dMemCollection)
        buffer.Append(cacheEntry)
        cacheEntry = String.Format("Poll Time: {0} <br/>", pollTime.ToString())
        buffer.Append(cacheEntry)
        cacheEntry = String.Format("Memory Limit: {0} <br/>", phMemUse.ToString())
        buffer.Append(cacheEntry)
        cacheEntry = String.Format("Bytes Limit: {0} <br/>", pvBytesLimit.ToString())
        buffer.Append(cacheEntry)

        Label1.Text = buffer.ToString()
    End Sub
End Class

설명

CacheSection 클래스를 사용하면 구성 파일의 <cache> 섹션을 프로그래밍 방식으로 액세스하고 수정할 수 있습니다.

ASP.NET 캐싱 기능에 의해 구현 됩니다는 Cache 클래스입니다. 자세한 내용은 캐싱합니다.

참고

합니다 CacheSection section 속성으로 정의 된 제한에 따라 구성 파일의 관련된 섹션에 정보를 작성할 수 있습니다 AllowDefinition 값인 MachineToApplication합니다. 계층에서 허용 되지 않습니다 수준에서 구성 파일에 쓰려고 시도 파서에 의해 생성 된 오류 메시지가 발생 합니다. 그러나 계층의 모든 수준에서 구성 정보를 읽을이 클래스를 사용할 수 있습니다.

캐시는 자주 액세스 하는 저장소 데이터에 사용 되는 애플리케이션별 해시 테이블입니다. 애플리케이션 및 세션 상태 캐시에 애플리케이션 상태는 가장 유사한, 애플리케이션 범위의 인해 비슷합니다. 캐시와 애플리케이션 상태 메커니즘의 가장 큰 차이점 중 하나는 캐시 지 종속성 이러한 종속성을 사용 하면 특정 이벤트가 발생할 때 자동으로 캐시 된 항목을 제거 하는 애플리케이션을 빌드할 수 있습니다.

생성자

CacheSection()

CacheSection 클래스의 새 인스턴스를 초기화합니다.

속성

CurrentConfiguration

현재 Configuration 인스턴스가 속해 있는 구성 계층 구조를 나타내는 최상위 ConfigurationElement 인스턴스에 대한 참조를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
DefaultProvider

기본 공급자를 가져오거나 설정합니다.

DisableExpiration

캐시 만료가 비활성화되었는지 여부를 나타내는 값을 가져오거나 설정합니다.

DisableMemoryCollection

캐시 메모리 수집이 비활성화되었는지 여부를 나타내는 값을 가져오거나 설정합니다.

ElementInformation

ElementInformation 개체의 사용자 지정할 수 없는 정보와 기능을 포함하는 ConfigurationElement 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
ElementProperty

ConfigurationElementProperty 개체 자체를 나타내는 ConfigurationElement 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
EvaluationContext

ContextInformation 개체의 ConfigurationElement 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
HasContext

CurrentConfiguration 속성이 null인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
Item[ConfigurationProperty]

이 구성 요소의 속성이나 특성을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElement)
Item[String]

이 구성 요소의 속성, 특성 또는 자식 요소를 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElement)
LockAllAttributesExcept

잠긴 특성의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockAllElementsExcept

잠긴 요소의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockAttributes

잠긴 특성의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockElements

잠긴 요소의 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
LockItem

요소가 잠겨 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 ConfigurationElement)
PercentagePhysicalMemoryUsedLimit

최대 가상 메모리 사용률을 나타내는 값을 가져오거나 설정합니다.

PrivateBytesLimit

작업 프로세스 프라이빗 공간의 최대 크기를 나타내는 값을 가져오거나 설정합니다.

PrivateBytesPollTime

작업자 프로세스 메모리 사용을 폴링하는 시간 간격을 나타내는 값을 가져오거나 설정합니다.

Properties

속성 컬렉션을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
Providers

공급자 설정 컬렉션을 가져옵니다.

SectionInformation

사용자가 지정할 수 없는 SectionInformation 개체의 정보와 기능을 포함하는 ConfigurationSection 개체를 가져옵니다.

(다음에서 상속됨 ConfigurationSection)

메서드

DeserializeElement(XmlReader, Boolean)

구성 파일에서 XML을 읽습니다.

(다음에서 상속됨 ConfigurationElement)
DeserializeSection(XmlReader)

구성 파일에서 XML을 읽습니다.

(다음에서 상속됨 ConfigurationSection)
Equals(Object)

현재 ConfigurationElement 인스턴스를 지정된 개체와 비교합니다.

(다음에서 상속됨 ConfigurationElement)
GetHashCode()

현재 ConfigurationElement 인스턴스를 나타내는 고유 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
GetRuntimeObject()

파생 클래스에서 재정의될 때 사용자 지정 개체를 반환합니다.

(다음에서 상속됨 ConfigurationSection)
GetTransformedAssemblyString(String)

지정된 어셈블리 이름의 변환된 버전을 반환합니다.

(다음에서 상속됨 ConfigurationElement)
GetTransformedTypeString(String)

지정된 형식 이름의 변환된 버전을 반환합니다.

(다음에서 상속됨 ConfigurationElement)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
Init()

ConfigurationElement 개체를 초기 상태로 설정합니다.

(다음에서 상속됨 ConfigurationElement)
InitializeDefault()

ConfigurationElement 개체 값의 기본 집합을 초기화하는 데 사용됩니다.

(다음에서 상속됨 ConfigurationElement)
IsModified()

이 구성 요소가 파생 클래스에서 구현되었을 때 마지막으로 저장되거나 로드된 이후 수정되었는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationSection)
IsReadOnly()

ConfigurationElement 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
ListErrors(IList)

ConfigurationElement 개체와 모든 하위 요소의 잘못된 속성 오류를 전달된 목록에 추가합니다.

(다음에서 상속됨 ConfigurationElement)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnDeserializeUnrecognizedAttribute(String, String)

역직렬화하는 동안 알 수 없는 특성을 발견했는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

역직렬화하는 동안 알 수 없는 요소를 발견했는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 ConfigurationElement)
OnRequiredPropertyNotFound(String)

필수 속성이 없으면 예외를 throw합니다.

(다음에서 상속됨 ConfigurationElement)
PostDeserialize()

deserialization 후에 호출됩니다.

(다음에서 상속됨 ConfigurationElement)
PreSerialize(XmlWriter)

serialization 전에 호출됩니다.

(다음에서 상속됨 ConfigurationElement)
Reset(ConfigurationElement)

잠금 및 속성 컬렉션을 비롯하여 ConfigurationElement 개체의 내부 상태를 다시 설정합니다.

(다음에서 상속됨 ConfigurationElement)
ResetModified()

파생 클래스에서 구현되는 경우 IsModified() 메서드의 값을 false로 다시 설정합니다.

(다음에서 상속됨 ConfigurationSection)
SerializeElement(XmlWriter, Boolean)

파생 클래스에서 구현될 때 구성 요소의 내용을 구성 파일에 씁니다.

(다음에서 상속됨 ConfigurationElement)
SerializeSection(ConfigurationElement, String, ConfigurationSaveMode)

ConfigurationSection 개체의 병합되지 않은 뷰가 들어 있는 XML 문자열을 파일에 쓸 단일 섹션으로 만듭니다.

(다음에서 상속됨 ConfigurationSection)
SerializeToXmlElement(XmlWriter, String)

파생 클래스에서 구현될 때 구성 요소의 외부 태그를 구성 파일에 씁니다.

(다음에서 상속됨 ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

속성을 지정된 값으로 설정합니다.

(다음에서 상속됨 ConfigurationElement)
SetReadOnly()

IsReadOnly() 개체와 모든 하위 요소에 대한 ConfigurationElement 속성을 설정합니다.

(다음에서 상속됨 ConfigurationElement)
ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName)

구성 개체 계층이 .NET Framework 지정된 대상 버전에 대해 직렬화될 때 지정된 요소를 serialize해야 하는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationSection)
ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement)

구성 개체 계층이 .NET Framework 지정된 대상 버전에 대해 serialize될 때 지정된 속성을 serialize해야 하는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationSection)
ShouldSerializeSectionInTargetVersion(FrameworkName)

구성 개체 계층 구조가 지정된 대상 버전의 .NET Framework 직렬화될 때 현재 ConfigurationSection 인스턴스를 serialize해야 하는지 여부를 나타냅니다.

(다음에서 상속됨 ConfigurationSection)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

ConfigurationElement 개체를 수정하여 저장되지 않아야 하는 값을 모두 제거합니다.

(다음에서 상속됨 ConfigurationElement)

적용 대상

추가 정보