Partager via


Suppression d'un rappel de notification de cache (mise en cache de Windows Server AppFabric)

Windows Server AppFabric permet à votre application prenant en charge le cache de recevoir des notifications de cache. Une fois que vous avez ajouté un rappel de notification de cache, l'application continue à recevoir des notifications jusqu'à ce que vous supprimiez le rappel. Cette rubrique décrit la suppression d'un rappel de notification de cache. Pour plus d'informations sur les notifications de cache en général, consultez la rubrique Notifications du cache (mise en cache de Windows Server AppFabric).

La méthode RemoveCallback permet de supprimer un rappel de notification de cache. Pour identifier la notification, cette méthode requiert l'objet DataCacheNotificationDescriptor renvoyé lorsque vous avez ajouté le rappel. Pour tenir compte de cette exigence, déclarez votre objet DataCacheNotificationDescriptor sur une étendue accessible par le code dans l'application qui ajoute le rappel et le code dans l'application qui supprime le rappel. L'objet DataCacheNotificationDescriptor renvoyé à la méthode appelée par la notification de cache peut également être utilisé pour supprimer un rappel.

Notes

Pour que votre application utilise les notifications, vous devez activer ces dernières sur un cache nommé. Utilisez le paramètre notificationsEnabled avec la commande New-Cache ou Set-CacheConfig. Pour plus d’informations, consultez la rubrique Utilisation de Windows PowerShell pour la gestion des fonctionnalités de mise en cache de Windows Server AppFabric.

Suppression d'un rappel de notification de cache

  1. Déclarez l'objet DataCacheNotificationDescriptor que vous avez utilisé pour ajouter un rappel sur une étendue accessible par le code de suppression du rappel.

  2. La méthode RemoveCallback permet de supprimer le rappel de notification de cache. Utilisez l'objet DataCacheNotificationDescriptor approprié pour le paramètre nd.

Exemple

Dans cet exemple, le client de cache et trois objets DataCacheNotificationDescriptor sont déclarés au niveau de la classe afin que les méthodes d'ajout et de suppression des rappels puissent y accéder.

'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;

La démarche décrite dans cet exemple utilise la méthode RemoveCallback pour supprimer les rappels correspondant aux trois objets DataCacheNotificationDescriptor de l'exemple précédent.

'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);
}

Voir aussi

Concepts

Ajout d'un rappel de notification de cache (mise en cache de Windows Server AppFabric)
Ajout d'un rappel de notification d'échec (mise en cache de Windows Server AppFabric)
Méthodes de notifications de cache (mise en cache de Windows Server AppFabric)
Utilisation de Windows PowerShell pour la gestion des fonctionnalités de mise en cache de Windows Server AppFabric

  2011-12-05