36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace StellaOps.Provcache.Postgres;
|
|
|
|
public sealed partial class PostgresProvcacheRepository
|
|
{
|
|
/// <inheritdoc />
|
|
public async Task<ProvcacheEntry?> GetAsync(string veriKey, CancellationToken cancellationToken = default)
|
|
{
|
|
var entity = await _context.ProvcacheItems
|
|
.AsNoTracking()
|
|
.FirstOrDefaultAsync(e => e.VeriKey == veriKey, cancellationToken)
|
|
.ConfigureAwait(false);
|
|
|
|
return entity is null ? null : MapToEntry(entity);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task<IReadOnlyDictionary<string, ProvcacheEntry>> GetManyAsync(
|
|
IEnumerable<string> veriKeys,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
var keyList = veriKeys.ToList();
|
|
if (keyList.Count == 0)
|
|
return new Dictionary<string, ProvcacheEntry>();
|
|
|
|
var entities = await _context.ProvcacheItems
|
|
.AsNoTracking()
|
|
.Where(e => keyList.Contains(e.VeriKey))
|
|
.ToListAsync(cancellationToken)
|
|
.ConfigureAwait(false);
|
|
|
|
return entities.ToDictionary(e => e.VeriKey, MapToEntry);
|
|
}
|
|
}
|