| | | 1 | | using Elsa.Caching; |
| | | 2 | | using Elsa.Common.Models; |
| | | 3 | | using Elsa.Workflows.Management.Filters; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Workflows.Management.Services; |
| | | 6 | | |
| | | 7 | | /// <inheritdoc /> |
| | 1 | 8 | | public class WorkflowDefinitionCacheManager(ICacheManager cache, IHasher hasher) : IWorkflowDefinitionCacheManager |
| | | 9 | | { |
| | | 10 | | /// <inheritdoc /> |
| | 1177 | 11 | | public ICacheManager Cache => cache; |
| | | 12 | | |
| | | 13 | | /// <inheritdoc /> |
| | 2 | 14 | | public string CreateWorkflowDefinitionVersionCacheKey(string definitionId, VersionOptions versionOptions) => $"Workf |
| | | 15 | | |
| | | 16 | | /// <inheritdoc /> |
| | | 17 | | public string CreateWorkflowDefinitionFilterCacheKey(WorkflowDefinitionFilter filter) |
| | | 18 | | { |
| | 520 | 19 | | var hash = hasher.Hash(filter); |
| | 520 | 20 | | return $"WorkflowDefinition:{hash}"; |
| | | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | 35 | 24 | | public string CreateWorkflowVersionCacheKey(string definitionId, VersionOptions versionOptions) => $"Workflow:{defin |
| | | 25 | | |
| | | 26 | | /// <inheritdoc /> |
| | 231 | 27 | | public string CreateWorkflowVersionCacheKey(string definitionVersionId) => $"Workflow:{definitionVersionId}"; |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | | 30 | | public string CreateWorkflowFilterCacheKey(WorkflowDefinitionFilter filter) |
| | | 31 | | { |
| | 390 | 32 | | var hash = hasher.Hash(filter); |
| | 390 | 33 | | return $"Workflow:{hash}"; |
| | | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <inheritdoc /> |
| | 0 | 37 | | public string CreateWorkflowDefinitionVersionCacheKey(string definitionVersionId) => $"WorkflowDefinition:{definitio |
| | | 38 | | |
| | | 39 | | /// <inheritdoc /> |
| | 1164 | 40 | | public string CreateWorkflowDefinitionChangeTokenKey(string definitionId) => $"WorkflowChangeToken:{definitionId}"; |
| | | 41 | | |
| | | 42 | | /// <inheritdoc /> |
| | | 43 | | public async Task EvictWorkflowDefinitionAsync(string definitionId, CancellationToken cancellationToken = default) |
| | | 44 | | { |
| | 643 | 45 | | var changeTokenKey = CreateWorkflowDefinitionChangeTokenKey(definitionId); |
| | 643 | 46 | | await cache.TriggerTokenAsync(changeTokenKey, cancellationToken); |
| | 643 | 47 | | } |
| | | 48 | | } |