| | | 1 | | using Elsa.Caching; |
| | | 2 | | using Elsa.Http.Bookmarks; |
| | | 3 | | using Elsa.Workflows; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Http.Services; |
| | | 6 | | |
| | | 7 | | /// <inheritdoc /> |
| | 1 | 8 | | public class HttpWorkflowsCacheManager(ICacheManager cache, IHasher bookmarkHasher) : IHttpWorkflowsCacheManager |
| | | 9 | | { |
| | | 10 | | /// <inheritdoc /> |
| | 215 | 11 | | public ICacheManager Cache => cache; |
| | | 12 | | |
| | | 13 | | /// <inheritdoc /> |
| | | 14 | | public async Task EvictWorkflowAsync(string workflowDefinitionId, CancellationToken cancellationToken = default) |
| | | 15 | | { |
| | 929 | 16 | | var changeTokenKey = GetWorkflowChangeTokenKey(workflowDefinitionId); |
| | 929 | 17 | | await cache.TriggerTokenAsync(changeTokenKey, cancellationToken); |
| | 929 | 18 | | } |
| | | 19 | | |
| | | 20 | | /// <inheritdoc /> |
| | | 21 | | public async Task EvictTriggerAsync(string bookmarkHash, CancellationToken cancellationToken = default) |
| | | 22 | | { |
| | 17 | 23 | | var changeTokenKey = GetTriggerChangeTokenKey(bookmarkHash); |
| | 17 | 24 | | await cache.TriggerTokenAsync(changeTokenKey, cancellationToken); |
| | 17 | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <inheritdoc /> |
| | 1136 | 28 | | public string GetWorkflowChangeTokenKey(string workflowDefinitionId) => $"{GetType().FullName}:workflow:{workflowDef |
| | | 29 | | |
| | | 30 | | /// <inheritdoc /> |
| | 227 | 31 | | public string GetTriggerChangeTokenKey(string bookmarkHash) => $"{GetType().FullName}:trigger:{bookmarkHash}:changeT |
| | | 32 | | |
| | | 33 | | /// <inheritdoc /> |
| | | 34 | | public string ComputeBookmarkHash(string path, string method) |
| | | 35 | | { |
| | 1 | 36 | | var bookmarkPayload = new HttpEndpointBookmarkPayload(path, method); |
| | 1 | 37 | | return bookmarkHasher.Hash(HttpStimulusNames.HttpEndpoint, bookmarkPayload); |
| | | 38 | | } |
| | | 39 | | } |