Class DatabaseServerMessengerNotificationHandler
Ensures that distributed cache events are setup and the IServerMessenger is initialized
Inheritance
Namespace: Umbraco.Cms.Core.Cache
Assembly: Umbraco.Infrastructure.dll
Syntax
public sealed class DatabaseServerMessengerNotificationHandler : INotificationHandler<UmbracoApplicationStartingNotification>, INotificationHandler<UmbracoRequestEndNotification>, INotificationAsyncHandler<UmbracoRequestEndNotification>, INotificationHandler
Constructors
View SourceDatabaseServerMessengerNotificationHandler(IServerMessenger, IUmbracoDatabaseFactory, ILogger<DatabaseServerMessengerNotificationHandler>, IRuntimeState)
Initializes a new instance of the DatabaseServerMessengerNotificationHandler class.
Declaration
[Obsolete("Please use the constructor with all parameters. Scheduled for removal in Umbraco 19.")]
public DatabaseServerMessengerNotificationHandler(IServerMessenger serverMessenger, IUmbracoDatabaseFactory databaseFactory, ILogger<DatabaseServerMessengerNotificationHandler> logger, IRuntimeState runtimeState)
Parameters
| Type | Name | Description |
|---|---|---|
| IServerMessenger | serverMessenger | |
| IUmbracoDatabaseFactory | databaseFactory | |
| ILogger<DatabaseServerMessengerNotificationHandler> | logger | |
| IRuntimeState | runtimeState |
DatabaseServerMessengerNotificationHandler(IServerMessenger, IUmbracoDatabaseFactory, ILogger<DatabaseServerMessengerNotificationHandler>, IRuntimeState, IRepositoryCacheVersionService)
Initializes a new instance of the DatabaseServerMessengerNotificationHandler class.
Declaration
public DatabaseServerMessengerNotificationHandler(IServerMessenger serverMessenger, IUmbracoDatabaseFactory databaseFactory, ILogger<DatabaseServerMessengerNotificationHandler> logger, IRuntimeState runtimeState, IRepositoryCacheVersionService repositoryCacheVersionService)
Parameters
| Type | Name | Description |
|---|---|---|
| IServerMessenger | serverMessenger | |
| IUmbracoDatabaseFactory | databaseFactory | |
| ILogger<DatabaseServerMessengerNotificationHandler> | logger | |
| IRuntimeState | runtimeState | |
| IRepositoryCacheVersionService | repositoryCacheVersionService |
Methods
View SourceHandle(UmbracoApplicationStartingNotification)
Handles a notification.
Declaration
public void Handle(UmbracoApplicationStartingNotification notification)
Parameters
| Type | Name | Description |
|---|---|---|
| UmbracoApplicationStartingNotification | notification | The notification. |
Handle(UmbracoRequestEndNotification)
Handles a notification.
Declaration
[Obsolete("Please use HandleAsync. Scheduled for removal in Umbraco 19.")]
public void Handle(UmbracoRequestEndNotification notification)
Parameters
| Type | Name | Description |
|---|---|---|
| UmbracoRequestEndNotification | notification | The notification. |
HandleAsync(UmbracoRequestEndNotification, CancellationToken)
Handles the end of an Umbraco request: writes the batched distributed cache instructions, then publishes the repository cache versions deferred during the request.
Declaration
public Task HandleAsync(UmbracoRequestEndNotification notification, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| UmbracoRequestEndNotification | notification | The notification instance signaling the end of an Umbraco request. |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
Remarks
The order matters. A server that sees a new cache version before the matching instruction syncs, finds nothing to refresh and keeps its stale entries until the next periodic sync.