An implementation of CacheInvalidator based on Microsoft Azure Service Bus, using the Azure.Messaging.ServiceBus API
meant for .NET Standard.
Inheritance
Implements
Namespace: PostSharp.Patterns.Caching.Backends.Azure
Assembly: PostSharp.Patterns.Caching.Backends.Azure.dll
Syntax
public class AzureServiceBusCacheInvalidator : CacheInvalidator, IDisposableRemarks
Use this component to synchronize the local in-memory caches of several instances of an application. Create it with Create(CachingBackend, AzureServiceBusCacheInvalidatorOptions) or CreateAsync(CachingBackend, AzureServiceBusCacheInvalidatorOptions), passing the local caching backend, and assign the result to DefaultBackend. Invalidation is asynchronous, so different instances can return different data for a short time.
Each instance of the invalidator needs its own topic subscription. When SubscriptionName
is null, the invalidator creates a subscription with a random name, which Azure Service Bus deletes after
AutoDeleteOnIdle. This requires the connection string to grant the Manage right.
Otherwise, create one subscription per application instance and set its name in SubscriptionName.
Methods
| Name | Description |
|---|---|
| Create(CachingBackend, AzureServiceBusCacheInvalidatorOptions) | Creates a new AzureServiceBusCacheInvalidator and blocks until a subscription is established. |
| CreateAsync(CachingBackend, AzureServiceBusCacheInvalidatorOptions) | Asynchronously creates a new AzureServiceBusCacheInvalidator. |
| DisposeAsyncCore(CancellationToken) | Asynchronously disposes the current CachingBackend. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked. |
| DisposeCore(bool) | Synchronously disposes the current CachingBackend. This protected method is part of the implementation API and is meant to be overridden in user code, not invoked. |
| ~AzureServiceBusCacheInvalidator() | Destructor. |
| SendMessageAsync(string, CancellationToken) | Sends an invalidation message over the message bus of the implementation. |