public async Task <Unit> Handle(SaveApplicationSettingsCommand request, CancellationToken cancellationToken) { await _applicationSettingsDomainEntity.GetAsync(cancellationToken); _applicationSettingsDomainEntity.MapFrom(request, _mapper); await _applicationSettingsDomainEntity.UpsertAsync(cancellationToken); return(Unit.Value); }
public async Task <ApplicationSettings> GetAsync(bool refreshCache, CancellationToken cancellationToken = default) { var cacheValue = await _cache.GetAsync(CacheKey, cancellationToken); if (refreshCache || cacheValue == null) { _applicationSettingsDomainEntity.WithOptions(x => x.AsNoTracking = true); await _applicationSettingsDomainEntity.GetAsync(cancellationToken); var applicationSettings = _applicationSettingsDomainEntity.Entity; var cacheEntryOptions = new DistributedCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromMinutes(10)); await _cache.SetAsync(CacheKey, Encode(applicationSettings), cacheEntryOptions, cancellationToken); return(applicationSettings); } else { return(Decode(cacheValue)); } }