initial commit

This commit is contained in:
Kukks
2023-01-16 10:31:48 +01:00
parent 136273406c
commit 25ccd99558
171 changed files with 10592 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using System.Threading.Tasks;
using BTCPayServer.Abstractions.Contracts;
using Microsoft.Extensions.Caching.Memory;
namespace BTCPayServer.Plugins.LSP;
public class LSPService
{
private readonly IMemoryCache _memoryCache;
private readonly IStoreRepository _storeRepository;
public LSPService(IMemoryCache memoryCache,
IStoreRepository storeRepository)
{
_memoryCache = memoryCache;
_storeRepository = storeRepository;
}
public async Task<LSPSettings> GetLSPForStore(string storeId)
{
var k = $"{nameof(LSPSettings)}_{storeId}";
return await _memoryCache.GetOrCreateAsync(k, async _ =>
{
var res = await _storeRepository.GetSettingAsync<LSPSettings>(storeId,
nameof(LSPSettings));
return res;
});
}
public async Task SetLSPForStore(string storeId, LSPSettings lspSettings)
{
var k = $"{nameof(LSPSettings)}_{storeId}";
await _storeRepository.UpdateSetting(storeId, nameof(LSPSettings), lspSettings);
_memoryCache.Set(k, lspSettings);
}
}