12
HA, locking, and callbacks

Windows Server AppFabric Cache

Embed Size (px)

DESCRIPTION

Windows Server AppFabric Cache. HA, locking, and callbacks. Outline. High-availability Pessimistic concurrency Cache callbacks. High availability. Generally used with Activity data - PowerPoint PPT Presentation

Citation preview

Page 1: Windows Server AppFabric Cache

HA, locking, and callbacks

Page 2: Windows Server AppFabric Cache
Page 3: Windows Server AppFabric Cache
Page 4: Windows Server AppFabric Cache

ApplicationApplicationApplicationApplication

PUT(K2, V2)

Cache2Cache2Cache1Cache1 Cache3Cache3

Primary for Primary for

Get(K2)

Primary forPrimary for Primary forPrimary for

K3, V3

AppFabric Caching ClientAppFabric Caching Client Routing

TableRouting Table

K2

, V2

Secondary forSecondary for

K2, V2

K1, V1

Secondary for Secondary for

K3, V3

Secondary forSecondary for

K1, V1

AppFabric Caching ClientAppFabric Caching Client

Routing TableRouting Table

K2, V2

Replication AgentReplication Agent

Page 5: Windows Server AppFabric Cache
Page 6: Windows Server AppFabric Cache

K1

• GetAndLock works on non-existent keys– Allows you to co-ordinate creating new object amongst

multiple clients

Client1: GetAndLock ("k1")

Client2: GetAndLock ("k1")

Client3: Get ("k1")

Regular Get succeeds

Regular Get succeeds

GetAndLock gets lock handle

GetAndLock gets lock handle

Other GetAndLock on same item fails Other GetAndLock on same item fails

Page 7: Windows Server AppFabric Cache
Page 8: Windows Server AppFabric Cache

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

Page 9: Windows Server AppFabric Cache

namespace Microsoft.ApplicationServer.Caching{ [Flags] public enum DataCacheOperations { AddItem = 1, ReplaceItem = 2, RemoveItem = 4, CreateRegion = 8, RemoveRegion = 16, ClearRegion = 32, }}

Page 10: Windows Server AppFabric Cache

New-Cache CallBackCache -NotificationsEnabled true

var cfg = new DataCacheFactoryConfiguration();cfg.Servers = new List<DataCacheServerEndpoint> { 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(); });

Page 11: Windows Server AppFabric Cache
Page 12: Windows Server AppFabric Cache