コード例 #1
0
 private async ValueTask <IDictionary <string, ActivityType> > GetDictionaryAsync(CancellationToken cancellationToken)
 {
     return(await _memoryCache.GetOrCreate(CacheKey, async entry =>
     {
         entry.Monitor(_cacheSignal.GetToken(CacheKey));
         return await GetActivityTypesInternalAsync(cancellationToken).ToDictionaryAsync(x => x.TypeName, cancellationToken);
     }));
 }
コード例 #2
0
 private async Task <ICollection <IWorkflowBlueprint> > ListInternalAsync(CancellationToken cancellationToken)
 {
     return(await _memoryCache.GetOrCreateAsync(CacheKey, async entry =>
     {
         entry.Monitor(_cacheSignal.GetToken(CacheKey));
         return await _workflowRegistry.ListAsync(cancellationToken).ToList();
     }));
 }
コード例 #3
0
        public override ValueTask SaveAsync(WorkflowStorageContext context, string key, object?value, CancellationToken cancellationToken = default)
        {
            var workflowInstanceId = context.WorkflowInstance.Id;
            var activityId         = context.ActivityId;
            var cacheKey           = GetKey(workflowInstanceId, activityId, key);
            var options            = new MemoryCacheEntryOptions();

            options.ExpirationTokens.Add(_cacheSignal.GetToken(GetSignalKey(workflowInstanceId)));
            _cache.Set(cacheKey, value, options);

            return(new ValueTask());
        }
コード例 #4
0
        public async Task <IWorkflowBlueprint?> FindInternalAsync(string cacheKey, Func <Task <IWorkflowBlueprint?> > findAction, CancellationToken cancellationToken = default)
        {
            return(await _memoryCache.GetOrCreateAsync(cacheKey, async entry =>
            {
                var workflowBlueprint = await findAction();

                if (workflowBlueprint != null)
                {
                    var key = GetEvictionKey(workflowBlueprint.Id);
                    entry.Monitor(_cacheSignal.GetToken(key));
                }

                return workflowBlueprint;
            }));
        }
コード例 #5
0
 public IChangeToken GetToken(string key) => _cacheSignal.GetToken(key);