| | | 1 | | using Elsa.Caching; |
| | | 2 | | using Elsa.Mediator.Contracts; |
| | | 3 | | using Elsa.Workflows.Runtime.Notifications; |
| | | 4 | | using Elsa.Workflows.Runtime.Stores; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Runtime.Handlers; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// A notification handler that invalidates triggers cache when workflow definitions are refreshed. |
| | | 11 | | /// </summary> |
| | | 12 | | /// <remarks> |
| | | 13 | | /// The class implements the <c>INotificationHandler</c> interface and is responsible for handling <c>WorkflowDefinition |
| | | 14 | | /// When a <c>WorkflowDefinitionsRefreshed</c> notification is received, the <c>HandleAsync</c> method is called to inva |
| | | 15 | | /// The cache is invalidated by calling the <c>TriggerTokenAsync</c> method of the <c>ICacheManager</c> passed to the cl |
| | | 16 | | /// </remarks> |
| | | 17 | | [UsedImplicitly] |
| | 319 | 18 | | public class InvalidateTriggersCache(ICacheManager cacheManager) : |
| | | 19 | | INotificationHandler<WorkflowDefinitionsRefreshed>, |
| | | 20 | | INotificationHandler<WorkflowDefinitionsReloaded> |
| | | 21 | | { |
| | | 22 | | /// <inheritdoc /> |
| | | 23 | | public Task HandleAsync(WorkflowDefinitionsRefreshed notification, CancellationToken cancellationToken) |
| | | 24 | | { |
| | 1 | 25 | | return cacheManager.TriggerTokenAsync(CachingTriggerStore.CacheInvalidationTokenKey, cancellationToken).AsTask() |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <inheritdoc /> |
| | | 29 | | public async Task HandleAsync(WorkflowDefinitionsReloaded notification, CancellationToken cancellationToken) |
| | | 30 | | { |
| | 6 | 31 | | await cacheManager.TriggerTokenAsync(CachingTriggerStore.CacheInvalidationTokenKey, cancellationToken); |
| | 6 | 32 | | } |
| | | 33 | | } |