CacheItemPolicy 클래스

정의

특정 캐시 엔트리에 대한 제거 집합과 만료 정보를 나타냅니다.

public ref class CacheItemPolicy
public class CacheItemPolicy
type CacheItemPolicy = class
Public Class CacheItemPolicy
상속
CacheItemPolicy

예제

다음 예제에는 텍스트 파일에 대 한 경로 모니터링 하는 메모리 내 캐시에서 항목을 만드는 방법을 보여 줍니다. 캐시를 만듭니다는 CacheItemPolicy 집합과 개체를 AbsoluteExpiration 60 초 후 캐시를 제거 하는 속성입니다.

Protected Sub Button1_Click(ByVal sender As Object, _  
            ByVal e As System.EventArgs) Handles Button1.Click  
    Dim cache As ObjectCache = MemoryCache.Default  
    Dim fileContents As String = TryCast(cache("filecontents"), _  
            String)  
    If fileContents Is Nothing Then  
        Dim policy As New CacheItemPolicy()  
        policy.AbsoluteExpiration = _  
            DateTimeOffset.Now.AddSeconds(60.0)  
        Dim filePaths As New List(Of String)()  
     Dim cachedFilePath As String = Server.MapPath("~") & _  
         "\cacheText.txt"  
        filePaths.Add(cachedFilePath)  
        policy.ChangeMonitors.Add(New _  
            HostFileChangeMonitor(filePaths))  

        ' Fetch the file contents.  
        fileContents = File.ReadAllText(cachedFilePath)  
        cache.Set("filecontents", fileContents, policy)  
    End If  
    Label1.Text = fileContents  
End Sub  
protected void Button1_Click(object sender, EventArgs e)  
    {  
        ObjectCache cache = MemoryCache.Default;  
            string fileContents = cache["filecontents"] as string;  
            if (fileContents == null)  
            {  
                CacheItemPolicy policy = new CacheItemPolicy();  
                policy.AbsoluteExpiration =   
                    DateTimeOffset.Now.AddSeconds(60.0);  

                List<string> filePaths = new List<string>();  
             string cachedFilePath = Server.MapPath("~") +   
                 "\\cacheText.txt";  
             filePaths.Add(cachedFilePath);  

                policy.ChangeMonitors.Add(new   
                    HostFileChangeMonitor(filePaths));  

                // Fetch the file contents.  
                fileContents = File.ReadAllText(cachedFilePath);  

                cache.Set("filecontents", fileContents, policy);  

            }  

            Label1.Text = fileContents;  
        }  

설명

CacheItemPolicy 인스턴스 캐시 항목과 연결 될 수 있는 정보를 포함 합니다. 예를 들어, 캐시 항목을 경우 캐시에서 제거 하려는 CacheEntryUpdateArguments 개체 콜백 메서드로 전달 됩니다. UpdatedCacheItemPolicy 의 속성을 CacheEntryUpdateArguments 개체에 대 한 참조를 전달할 수를 CacheItemPolicy 캐시 엔트리에 대 한 제거 집합과 만료 정보를 포함할 수 있는 인스턴스.

일부 메서드는 MemoryCacheObjectCache 클래스에 동의 CacheItemPolicy 인스턴스를 제거 또는 만료 정책에 설명 합니다.

상속자 참고

CacheItemPolicy 사용자 지정 캐시 개발자가 확장할 수 있도록 형식이 sealed 아닙니다.

생성자

CacheItemPolicy()

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

속성

AbsoluteExpiration

지정된 시점에 캐시 엔트리를 제거해야 하는지 여부를 나타내는 값을 가져오거나 설정합니다.

ChangeMonitors

캐시 엔트리와 연결된 ChangeMonitor 개체의 컬렉션을 가져옵니다.

Priority

캐시 엔트리를 제거할지 여부를 결정하는 데 사용되는 우선 순위 설정을 가져오거나 설정합니다.

RemovedCallback

캐시에서 엔트리가 제거된 후 호출되는 CacheEntryRemovedCallback 대리자에 대한 참조를 가져오거나 설정합니다.

SlidingExpiration

지정된 시간 범위 내에 액세스되지 않은 경우 캐시 엔트리를 제거할지 여부를 나타내는 값을 가져오거나 설정합니다.

UpdateCallback

캐시에서 캐시 엔트리가 제거되기 전에 호출되는 CacheEntryUpdateCallback 대리자에 대한 참조를 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

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

기본 해시 함수로 작동합니다.

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

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상