AddItemLevelCallback Method (String, DataCacheOperations, DataCacheNotificationCallback)

Adds a cache notification callback for cache operations occurring on one specific item that is not stored in a region. Applies only to the server versions of AppFabric.

Namespace:  Microsoft.ApplicationServer.Caching
Assembly:  Microsoft.ApplicationServer.Caching.Client (in Microsoft.ApplicationServer.Caching.Client.dll)

public DataCacheNotificationDescriptor AddItemLevelCallback(
	string key,
	DataCacheOperations filter,
	DataCacheNotificationCallback clientCallback


Type: System..::..String
The key used to store the object in the cache.
Type: Microsoft.ApplicationServer.Caching..::..DataCacheOperations
The type of cache operation(s) that will trigger cache notifications.
Type: Microsoft.ApplicationServer.Caching..::..DataCacheNotificationCallback
The name of the method you want to invoke when these notifications occur.

Return Value

Type: Microsoft.ApplicationServer.Caching..::..DataCacheNotificationDescriptor
A DataCacheNotificationDescriptor object used to identify the cache notification callback.

Only item operations AddItem, ReplaceItem, and RemoveItem can trigger cache notifications with item-level callbacks. Specifying region operations in the filter parameter will cause an exception.

Use the DataCacheOperations enumeration in the filter parameter to specify what type of item operations you want to trigger cache notifications. Select more than one enumeration by separating the enumerations with the binary OR operator to perform a bitwise OR. To do this, use the | character in C#, and the Or operator in Visual Basic.

The clientCallback method you invoke with the cache notification must accept the same parameters as the DataCacheNotificationCallback delegate.

For more information about using this method, see <maml:externalLink><maml:linkText>Add a Cache Notification Callback</maml:linkText><maml:linkUri></maml:linkUri></maml:externalLink>. For more information about cache notifications, see <maml:externalLink><maml:linkText>Cache Notifications</maml:linkText><maml:linkUri></maml:linkUri></maml:externalLink>.


In order for your application to use notifications, you need to enable them on a named cache. Use the NotificationsEnabled parameter with the New-Cache or Set-CacheConfig commands. For more information, see <maml:externalLink><maml:linkText>Using Windows PowerShell to Manage Windows Server AppFabric Caching Features</maml:linkText><maml:linkUri></maml:linkUri></maml:externalLink>.