CS2-12: Удален интерфейс ICacheTable<T>

This commit is contained in:
KharchenkoVV 2021-05-20 14:14:51 +05:00
parent d57f495ff0
commit d45f8cb429
9 changed files with 11 additions and 52 deletions

View File

@ -9,7 +9,7 @@ namespace AsbCloudInfrastructure.Services.Cache
{
private readonly ConcurrentDictionary<string, IEnumerable<object>> cache = new ConcurrentDictionary<string, IEnumerable<object>>();
public ICacheTable<TEntity> GetCachedTable<TEntity>(DbContext context)
public CacheTable<TEntity> GetCachedTable<TEntity>(DbContext context)
where TEntity : class
{
var entityTypeName = typeof(TEntity).FullName;

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.Cache
{
class CacheTable<TEntity> : ICacheTable<TEntity> where TEntity : class
public class CacheTable<TEntity> where TEntity : class
{
private readonly DbContext context;
private readonly List<TEntity> cached;

View File

@ -1,41 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.Cache
{
public interface ICacheTable<TEntity> where TEntity : class
{
TEntity this[int index] { get; }
int Refresh();
bool Contains(Func<TEntity, bool> predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty);
TEntity FirstOrDefault(RefreshMode refreshMode = RefreshMode.IfResultEmpty);
TEntity FirstOrDefault(Func<TEntity, bool> predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty);
IEnumerable<TEntity> Insert(IEnumerable<TEntity> newEntities);
TEntity Insert(TEntity entity);
void Remove(Func<TEntity, bool> predicate);
IEnumerable<TEntity> Select(Func<TEntity, bool> predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty);
IEnumerable<TEntity> Update(Func<TEntity, bool> predicate, Action<TEntity> mutation);
TEntity Upsert(TEntity entity);
IEnumerable<TEntity> Upsert(IEnumerable<TEntity> entities);
//----- ASYNC ------
Task<int> RefreshAsync(CancellationToken token = default);
Task<bool> ContainsAsync(Func<TEntity, bool> predicate, CancellationToken token = default);
Task<bool> ContainsAsync(Func<TEntity, bool> predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty, CancellationToken token = default);
Task<TEntity> FirstOrDefaultAsync(CancellationToken token = default);
Task<TEntity> FirstOrDefaultAsync(RefreshMode refreshMode = RefreshMode.IfResultEmpty, CancellationToken token = default);
Task<TEntity> FirstOrDefaultAsync(Func<TEntity, bool> predicate, CancellationToken token = default);
Task<TEntity> FirstOrDefaultAsync(Func<TEntity, bool> predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty, CancellationToken token = default);
Task<IEnumerable<TEntity>> InsertAsync(IEnumerable<TEntity> newEntities, CancellationToken token = default);
Task<TEntity> InsertAsync(TEntity entity, CancellationToken token = default);
Task RemoveAsync(Func<TEntity, bool> predicate, CancellationToken token = default);
Task<IEnumerable<TEntity>> SelectAsync(Func<TEntity, bool> predicate, CancellationToken token = default);
Task<IEnumerable<TEntity>> SelectAsync(Func<TEntity, bool> predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty, CancellationToken token = default);
Task<IEnumerable<TEntity>> UpdateAsync(Func<TEntity, bool> predicate, Action<TEntity> mutation, CancellationToken token = default);
Task<TEntity> UpsertAsync(TEntity entity, CancellationToken token = default);
Task<IEnumerable<TEntity>> UpsertAsync(IEnumerable<TEntity> entities, CancellationToken token = default);
}
}

View File

@ -14,8 +14,8 @@ namespace AsbCloudInfrastructure.Services
private readonly IAsbCloudDbContext db;
private readonly ITelemetryService telemetryService;
private readonly IMapper mapper;
private readonly ICacheTable<Telemetry> cacheTelemetry;
private readonly ICacheTable<Well> cacheWells;
private readonly CacheTable<Telemetry> cacheTelemetry;
private readonly CacheTable<Well> cacheWells;
public DataService(IAsbCloudDbContext db, ITelemetryService telemetryService, CacheDb cacheDb, MapperConfiguration mapperConfiguration)
{

View File

@ -11,7 +11,7 @@ namespace AsbCloudInfrastructure.Services
{
private readonly IAsbCloudDbContext db;
private readonly ITelemetryService telemetryService;
private readonly ICacheTable<Event> cacheEvents;
private readonly CacheTable<Event> cacheEvents;
public EventService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService)
{

View File

@ -15,8 +15,8 @@ namespace AsbCloudInfrastructure.Services
private readonly IAsbCloudDbContext db;
private readonly ITelemetryService telemetryService;
private readonly IMapper mapper;
private readonly ICacheTable<Event> cacheEvents;
private readonly ICacheTable<TelemetryUser> cacheTUsers;
private readonly CacheTable<Event> cacheEvents;
private readonly CacheTable<TelemetryUser> cacheTUsers;
public MessageService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService, MapperConfiguration mapperConfiguration)
{

View File

@ -9,8 +9,8 @@ namespace AsbCloudInfrastructure.Services
public class TelemetryService : ITelemetryService
{
private readonly IMapper mapper;
private readonly ICacheTable<Telemetry> cacheTelemetry;
private readonly ICacheTable<Well> cacheWells;
private readonly CacheTable<Telemetry> cacheTelemetry;
private readonly CacheTable<Well> cacheWells;
public TelemetryService(IAsbCloudDbContext db, CacheDb cacheDb, MapperConfiguration mapperConfiguration)
{

View File

@ -11,7 +11,7 @@ namespace AsbCloudInfrastructure.Services
{
private readonly IAsbCloudDbContext db;
private readonly ITelemetryService telemetryService;
private readonly ICacheTable<TelemetryUser> cacheTUsers;
private readonly CacheTable<TelemetryUser> cacheTUsers;
public TelemetryUserService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService)
{

View File

@ -12,7 +12,7 @@ namespace AsbCloudInfrastructure.Services
{
private readonly IAsbCloudDbContext db;
private readonly ITelemetryTracker telemetryTracker;
private readonly ICacheTable<Well> cacheWells;
private readonly CacheTable<Well> cacheWells;
public WellService(IAsbCloudDbContext db, ITelemetryTracker telemetryTracker, CacheDb cacheDb)
{