ignoring strange issue.

This commit is contained in:
Фролов 2021-09-03 11:35:27 +05:00
parent 81e765581c
commit 187c83a7b1

View File

@ -13,7 +13,6 @@ namespace AsbCloudInfrastructure.Services.Cache
private (DateTime refreshDate, IEnumerable<object> entities) data;
private readonly List<TEntity> cached;
private readonly DbSet<TEntity> dbSet;
private readonly SemaphoreSlim semaphore = new SemaphoreSlim(1, 1);
internal CacheTable(DbContext context, (DateTime refreshDate, IEnumerable<object> entities) data)
{
@ -29,8 +28,16 @@ namespace AsbCloudInfrastructure.Services.Cache
{
if (cached.Any())
{
semaphore.Wait();
cached.Clear();
try
{
cached.Clear();
}
catch
{
// ignore
// TODO: figure out what the well
}
}
var dbEntities = context.Set<TEntity>().AsNoTracking().ToList();
cached.AddRange(dbEntities);
@ -42,8 +49,15 @@ namespace AsbCloudInfrastructure.Services.Cache
{
if (cached.Any())
{
await semaphore.WaitAsync(token).ConfigureAwait(true);
cached.Clear();
try
{
cached.Clear();
}
catch
{
// ignore
// TODO: figure out what the well
}
}
var dbEntities = await context.Set<TEntity>().AsNoTracking().ToListAsync(token).ConfigureAwait(false);
cached.AddRange(dbEntities);