public async Task Run(string tenantId, IJobCancellationToken cancellationToken) { try { Logger.Info($"Reading aggregatable attributes '{tenantId}'"); var dataContext = await _systemContext.CreateOrGetTenantContext(tenantId); foreach (var entityCacheItem in dataContext.CkCache.GetCkEntities()) { cancellationToken?.ThrowIfCancellationRequested(); foreach (var attributeCacheItem in entityCacheItem.Attributes) { if (!attributeCacheItem.Value.IsAutoCompleteEnabled) { continue; } cancellationToken?.ThrowIfCancellationRequested(); using var session = await dataContext.Repository.StartSessionAsync(); session.StartTransaction(); var autoCompleteTexts = await dataContext.Repository.ExtractAutoCompleteValuesAsync(session, entityCacheItem.CkId, attributeCacheItem.Value.AttributeName, attributeCacheItem.Value.AutoCompleteFilter, attributeCacheItem.Value.AutoCompleteLimit); await dataContext.Repository.UpdateAutoCompleteTexts(session, entityCacheItem.CkId, attributeCacheItem.Value.AttributeName, autoCompleteTexts.Select(x => x.Text)); await session.CommitTransactionAsync(); } } await _distributedCache.PublishAsync(CacheCommon.KeyTenantUpdate, tenantId); Logger.Info($"Aggregation of attribute values of data source '{tenantId}' completed."); } catch (Exception e) { Logger.Error(e, "Aggregation failed with error."); throw; } }
private async Task ClearCacheAsync() { await _distributedCache.PublishAsync(CacheCommon.KeyCorsClients, Guid.NewGuid().ToString()); }
private async Task ClearCacheAsync() { await _distributedCache.PublishAsync(CacheCommon.KeyIdentityProviderUpdate, Guid.NewGuid().ToString()); }
private async Task UnloadTenantCachesAsync(string tenantId) { await _distributedWithPubSubCache.PublishAsync(CacheCommon.KeyTenantUpdate, tenantId); RemoveCkCache(tenantId); }