Download presentation
Presentation is loading. Please wait.
Published byIyana Springs Modified over 10 years ago
1
HA, locking, and callbacks
4
Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table K2, V2 Secondary for K2, V2 K1, V1 Secondary for K3, V3 Secondary for K1, V1 AppFabric Caching Client Routing Table K2, V2 Replication Agent
6
K1 GetAndLock works on non-existent keys – Allows you to co-ordinate creating new object amongst multiple clients Client1: GetAndLock ("k1") Client1: GetAndLock ("k1") Client2: GetAndLock ("k1") Client2: GetAndLock ("k1") Client3: Get ("k1") Client3: Get ("k1") Regular Get succeeds GetAndLock gets lock handle Other GetAndLock on same item fails
8
public virtual DataCacheNotificationDescriptor AddCacheLevelBulkCallback(DataCacheBulkNotificationCallback clientCallback); public virtual DataCacheNotificationDescriptor AddCacheLevelCallback(DataCacheOperation filter, DataCacheNotificationCallback clientCallback); public virtual DataCacheNotificationDescriptor AddFailureNotificationCallback(DataCacheFailureNotificationCallback failureCallback); public virtual DataCacheNotificationDescriptor AddItemLevelCallback(string key, DataCacheOperation filter, DataCacheNotificationCallback clientCallback); public virtual DataCacheNotificationDescriptor AddItemLevelCallback(string key, DataCacheOperation filter, DataCacheNotificationCallback clientCallback, string regionName); public virtual DataCacheNotificationDescriptor AddRegionLevelCallback(string regionName, DataCacheOperation filter, DataCacheNotificationCallback clientCallback);
9
namespace Microsoft.ApplicationServer.Caching { [Flags] public enum DataCacheOperations { AddItem = 1, ReplaceItem = 2, RemoveItem = 4, CreateRegion = 8, RemoveRegion = 16, ClearRegion = 32, }
10
New-Cache CallBackCache -NotificationsEnabled true var cfg = new DataCacheFactoryConfiguration(); cfg.Servers = new List { new DataCacheServerEndpoint("demo2010a", 22233) }; var dcf = new DataCacheFactory(cfg); var cache1 = dcf.GetCache("CallBackCache"); var d = cache1.AddCacheLevelCallback(DataCacheOperations.AddItem, ( cacheName, regionName, key, version, cacheOperation, nd) => { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("New item added to cache {0}", key); Console.ResetColor(); });
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.