Presentation is loading. Please wait.

Presentation is loading. Please wait.

HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table.

Similar presentations


Presentation on theme: "HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table."— Presentation transcript:

1 HA, locking, and callbacks

2

3

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

5

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

7

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

11

12


Download ppt "HA, locking, and callbacks. Application PUT(K2, V2) Cache2 Cache1 Cache3 Primary for Get(K2) Primary for K3, V3 AppFabric Caching Client Routing Table."

Similar presentations


Ads by Google