forked from ddrilling/AsbCloudServer
ignoring strange issue.
This commit is contained in:
parent
81e765581c
commit
187c83a7b1
@ -13,7 +13,6 @@ namespace AsbCloudInfrastructure.Services.Cache
|
|||||||
private (DateTime refreshDate, IEnumerable<object> entities) data;
|
private (DateTime refreshDate, IEnumerable<object> entities) data;
|
||||||
private readonly List<TEntity> cached;
|
private readonly List<TEntity> cached;
|
||||||
private readonly DbSet<TEntity> dbSet;
|
private readonly DbSet<TEntity> dbSet;
|
||||||
private readonly SemaphoreSlim semaphore = new SemaphoreSlim(1, 1);
|
|
||||||
|
|
||||||
internal CacheTable(DbContext context, (DateTime refreshDate, IEnumerable<object> entities) data)
|
internal CacheTable(DbContext context, (DateTime refreshDate, IEnumerable<object> entities) data)
|
||||||
{
|
{
|
||||||
@ -29,8 +28,16 @@ namespace AsbCloudInfrastructure.Services.Cache
|
|||||||
{
|
{
|
||||||
if (cached.Any())
|
if (cached.Any())
|
||||||
{
|
{
|
||||||
semaphore.Wait();
|
try
|
||||||
cached.Clear();
|
{
|
||||||
|
cached.Clear();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
// TODO: figure out what the well
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
var dbEntities = context.Set<TEntity>().AsNoTracking().ToList();
|
var dbEntities = context.Set<TEntity>().AsNoTracking().ToList();
|
||||||
cached.AddRange(dbEntities);
|
cached.AddRange(dbEntities);
|
||||||
@ -42,8 +49,15 @@ namespace AsbCloudInfrastructure.Services.Cache
|
|||||||
{
|
{
|
||||||
if (cached.Any())
|
if (cached.Any())
|
||||||
{
|
{
|
||||||
await semaphore.WaitAsync(token).ConfigureAwait(true);
|
try
|
||||||
cached.Clear();
|
{
|
||||||
|
cached.Clear();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
// TODO: figure out what the well
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var dbEntities = await context.Set<TEntity>().AsNoTracking().ToListAsync(token).ConfigureAwait(false);
|
var dbEntities = await context.Set<TEntity>().AsNoTracking().ToListAsync(token).ConfigureAwait(false);
|
||||||
cached.AddRange(dbEntities);
|
cached.AddRange(dbEntities);
|
||||||
|
Loading…
Reference in New Issue
Block a user