ha, locking, and callbacks. application put(k2, v2) cache2 cache1 cache3 primary for get(k2) primary...
Post on 01-Apr-2015
219 Views
Preview:
TRANSCRIPT
HA, locking, and callbacks
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
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
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);
namespace Microsoft.ApplicationServer.Caching{ [Flags] public enum DataCacheOperations { AddItem = 1, ReplaceItem = 2, RemoveItem = 4, CreateRegion = 8, RemoveRegion = 16, ClearRegion = 32, }}
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(); });
top related