diff --git a/EnvelopeGenerator.Application/Common/CacheKey.cs b/EnvelopeGenerator.Application/Common/CacheKey.cs new file mode 100644 index 00000000..993564cf --- /dev/null +++ b/EnvelopeGenerator.Application/Common/CacheKey.cs @@ -0,0 +1,13 @@ +namespace EnvelopeGenerator.Application.Common; + +// TODO: merge other cache keys here as well, e.g. for templates, etc. +/// +/// +/// +public static class CacheKey +{ + /// + /// + /// + public static readonly Guid DefaultConfig = Guid.NewGuid(); +} \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/ConfigService.cs b/EnvelopeGenerator.Application/Services/ConfigService.cs index 4b29fa6f..4d86781d 100644 --- a/EnvelopeGenerator.Application/Services/ConfigService.cs +++ b/EnvelopeGenerator.Application/Services/ConfigService.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging; using EnvelopeGenerator.Application.Common.Dto; using EnvelopeGenerator.Application.Common.Interfaces.Repositories; using EnvelopeGenerator.Application.Common.Interfaces.Services; +using EnvelopeGenerator.Application.Common; namespace EnvelopeGenerator.Application.Services; @@ -16,8 +17,6 @@ namespace EnvelopeGenerator.Application.Services; [Obsolete("Use MediatR")] public class ConfigService : ReadService, IConfigService { - private static readonly Guid DefaultConfigCacheId = Guid.NewGuid(); - private readonly IMemoryCache _cache; private readonly ILogger _logger; @@ -62,7 +61,7 @@ public class ConfigService : ReadService public async Task ReadDefaultAsync() { - var config = await _cache.GetOrCreateAsync(DefaultConfigCacheId, _ => ReadFirstAsync().ThenAsync( + var config = await _cache.GetOrCreateAsync(CacheKey.DefaultConfig, _ => ReadFirstAsync().ThenAsync( Success: config => config, Fail: (mssg, ntc) => {