캐시 알림 콜백 제거(Windows Server AppFabric 캐싱)

Windows Server AppFabric을 사용하면 캐시 사용 응용 프로그램이 캐시 알림을 받을 수 있습니다. 캐시 알림 콜백을 추가한 후 응용 프로그램은 콜백을 제거할 때까지 계속 캐시 알림을 받습니다. 이 항목에서는 캐시 알림 콜백을 제거하는 방법에 대해 설명합니다. 일반적인 캐시 알림에 대한 자세한 내용은 캐시 알림(Windows Server AppFabric 캐싱)을 참조하십시오.

RemoveCallback 메서드를 사용하여 캐시 알림 콜백을 제거할 수 있습니다. 알림을 식별하려면 이 메서드에 콜백을 추가할 때 반환된 DataCacheNotificationDescriptor 개체가 필요합니다. 이 요구 사항을 쉽게 충족하려면 콜백을 추가하는 응용 프로그램의 코드와 콜백을 제거하는 응용 프로그램의 코드에서 액세스할 수 있는 범위에 DataCacheNotificationDescriptor 개체를 선언합니다. 캐시 알림에서 호출된 메서드에 반환된 DataCacheNotificationDescriptor 개체를 사용하여 콜백을 제거할 수도 있습니다.

참고

응용 프로그램이 알림을 사용하려면 명명된 캐시에서 알림을 사용하도록 설정해야 합니다. New-Cache 또는 Set-CacheConfig 명령에 notificationsEnabled 매개 변수를 사용합니다. 자세한 내용은 Windows PowerShell을 사용하여 Windows Server AppFabric 캐싱 기능 관리를 참조하십시오.

콜백 캐시 알림을 제거하려면 다음을 수행하십시오.

  1. 콜백을 제거할 코드에서 액세스할 수 있는 범위에 콜백을 추가하는 데 사용하는 DataCacheNotificationDescriptor 개체를 선언합니다.

  2. RemoveCallback 메서드를 사용하여 캐시 알림 콜백을 제거합니다. nd 매개 변수에 적절한 DataCacheNotificationDescriptor 개체를 사용합니다.

예제

이 예에서 캐시 클라이언트와 세 개의 DataCacheNotificationDescriptor 개체는 콜백을 추가 및 제거하는 메서드가 액세스할 수 있도록 클래스 수준에서 선언됩니다.

'define variables for class
Dim myTestCache As DataCache
Dim ndCacheLvlAllOps As DataCacheNotificationDescriptor
Dim ndRegionLvlAllOps As DataCacheNotificationDescriptor
Dim ndItemLvlAllOps As DataCacheNotificationDescriptor
//define variables for class
DataCache myTestCache;
DataCacheNotificationDescriptor ndCacheLvlAllOps;
DataCacheNotificationDescriptor ndRegionLvlAllOps;
DataCacheNotificationDescriptor ndItemLvlAllOps;

이 예에서는 RemoveCallback 메서드를 사용하여 이전 예의 DataCacheNotificationDescriptor 개체 세 개에 해당하는 콜백을 제거하는 메서드를 보여 줍니다.

'remove cache notification callbacks
Public Sub RemoveNotificationCallbacks()
    myTestCache.RemoveCallback(ndCacheLvlAllOps)
    myTestCache.RemoveCallback(ndRegionLvlAllOps)
    myTestCache.RemoveCallback(ndItemLvlAllOps)
End Sub
//remove cache notification callbacks
public void RemoveNotificationCallbacks()
{
    myTestCache.RemoveCallback(ndCacheLvlAllOps);
    myTestCache.RemoveCallback(ndRegionLvlAllOps);
    myTestCache.RemoveCallback(ndItemLvlAllOps);
}

참고 항목

개념

캐시 알림 콜백 추가(Windows Server AppFabric 캐싱)
오류 알림 콜백 추가(Windows Server AppFabric 캐싱)
캐시 알림 메서드(Windows Server AppFabric 캐싱)
Windows PowerShell을 사용하여 Windows Server AppFabric 캐싱 기능 관리

  2011-12-05