diff --git a/AsbCloudInfrastructure/Services/Cache/CacheDb.cs b/AsbCloudInfrastructure/Services/Cache/CacheDb.cs index cb51a225..ddf34de8 100644 --- a/AsbCloudInfrastructure/Services/Cache/CacheDb.cs +++ b/AsbCloudInfrastructure/Services/Cache/CacheDb.cs @@ -9,7 +9,7 @@ namespace AsbCloudInfrastructure.Services.Cache { private readonly ConcurrentDictionary> cache = new ConcurrentDictionary>(); - public ICacheTable GetCachedTable(DbContext context) + public CacheTable GetCachedTable(DbContext context) where TEntity : class { var entityTypeName = typeof(TEntity).FullName; diff --git a/AsbCloudInfrastructure/Services/Cache/CacheTable.cs b/AsbCloudInfrastructure/Services/Cache/CacheTable.cs index 7b348643..4f85ea43 100644 --- a/AsbCloudInfrastructure/Services/Cache/CacheTable.cs +++ b/AsbCloudInfrastructure/Services/Cache/CacheTable.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace AsbCloudInfrastructure.Services.Cache { - class CacheTable : ICacheTable where TEntity : class + public class CacheTable where TEntity : class { private readonly DbContext context; private readonly List cached; diff --git a/AsbCloudInfrastructure/Services/Cache/ICacheTable.cs b/AsbCloudInfrastructure/Services/Cache/ICacheTable.cs deleted file mode 100644 index f7439906..00000000 --- a/AsbCloudInfrastructure/Services/Cache/ICacheTable.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace AsbCloudInfrastructure.Services.Cache -{ - public interface ICacheTable where TEntity : class - { - TEntity this[int index] { get; } - int Refresh(); - bool Contains(Func predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty); - TEntity FirstOrDefault(RefreshMode refreshMode = RefreshMode.IfResultEmpty); - TEntity FirstOrDefault(Func predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty); - IEnumerable Insert(IEnumerable newEntities); - TEntity Insert(TEntity entity); - void Remove(Func predicate); - IEnumerable Select(Func predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty); - IEnumerable Update(Func predicate, Action mutation); - TEntity Upsert(TEntity entity); - IEnumerable Upsert(IEnumerable entities); - - //----- ASYNC ------ - - Task RefreshAsync(CancellationToken token = default); - Task ContainsAsync(Func predicate, CancellationToken token = default); - Task ContainsAsync(Func predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty, CancellationToken token = default); - Task FirstOrDefaultAsync(CancellationToken token = default); - Task FirstOrDefaultAsync(RefreshMode refreshMode = RefreshMode.IfResultEmpty, CancellationToken token = default); - Task FirstOrDefaultAsync(Func predicate, CancellationToken token = default); - Task FirstOrDefaultAsync(Func predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty, CancellationToken token = default); - Task> InsertAsync(IEnumerable newEntities, CancellationToken token = default); - Task InsertAsync(TEntity entity, CancellationToken token = default); - Task RemoveAsync(Func predicate, CancellationToken token = default); - Task> SelectAsync(Func predicate, CancellationToken token = default); - Task> SelectAsync(Func predicate, RefreshMode refreshMode = RefreshMode.IfResultEmpty, CancellationToken token = default); - Task> UpdateAsync(Func predicate, Action mutation, CancellationToken token = default); - Task UpsertAsync(TEntity entity, CancellationToken token = default); - Task> UpsertAsync(IEnumerable entities, CancellationToken token = default); - } -} \ No newline at end of file diff --git a/AsbCloudInfrastructure/Services/DataService.cs b/AsbCloudInfrastructure/Services/DataService.cs index 5dc58c56..eb769b05 100644 --- a/AsbCloudInfrastructure/Services/DataService.cs +++ b/AsbCloudInfrastructure/Services/DataService.cs @@ -14,8 +14,8 @@ namespace AsbCloudInfrastructure.Services private readonly IAsbCloudDbContext db; private readonly ITelemetryService telemetryService; private readonly IMapper mapper; - private readonly ICacheTable cacheTelemetry; - private readonly ICacheTable cacheWells; + private readonly CacheTable cacheTelemetry; + private readonly CacheTable cacheWells; public DataService(IAsbCloudDbContext db, ITelemetryService telemetryService, CacheDb cacheDb, MapperConfiguration mapperConfiguration) { diff --git a/AsbCloudInfrastructure/Services/EventService.cs b/AsbCloudInfrastructure/Services/EventService.cs index b8762dda..551deef8 100644 --- a/AsbCloudInfrastructure/Services/EventService.cs +++ b/AsbCloudInfrastructure/Services/EventService.cs @@ -11,7 +11,7 @@ namespace AsbCloudInfrastructure.Services { private readonly IAsbCloudDbContext db; private readonly ITelemetryService telemetryService; - private readonly ICacheTable cacheEvents; + private readonly CacheTable cacheEvents; public EventService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService) { diff --git a/AsbCloudInfrastructure/Services/MessageService.cs b/AsbCloudInfrastructure/Services/MessageService.cs index cf643b9b..4ddd2e38 100644 --- a/AsbCloudInfrastructure/Services/MessageService.cs +++ b/AsbCloudInfrastructure/Services/MessageService.cs @@ -15,8 +15,8 @@ namespace AsbCloudInfrastructure.Services private readonly IAsbCloudDbContext db; private readonly ITelemetryService telemetryService; private readonly IMapper mapper; - private readonly ICacheTable cacheEvents; - private readonly ICacheTable cacheTUsers; + private readonly CacheTable cacheEvents; + private readonly CacheTable cacheTUsers; public MessageService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService, MapperConfiguration mapperConfiguration) { diff --git a/AsbCloudInfrastructure/Services/TelemetryService.cs b/AsbCloudInfrastructure/Services/TelemetryService.cs index 5691e0fe..d03b5f3c 100644 --- a/AsbCloudInfrastructure/Services/TelemetryService.cs +++ b/AsbCloudInfrastructure/Services/TelemetryService.cs @@ -9,8 +9,8 @@ namespace AsbCloudInfrastructure.Services public class TelemetryService : ITelemetryService { private readonly IMapper mapper; - private readonly ICacheTable cacheTelemetry; - private readonly ICacheTable cacheWells; + private readonly CacheTable cacheTelemetry; + private readonly CacheTable cacheWells; public TelemetryService(IAsbCloudDbContext db, CacheDb cacheDb, MapperConfiguration mapperConfiguration) { diff --git a/AsbCloudInfrastructure/Services/TelemetryUserService.cs b/AsbCloudInfrastructure/Services/TelemetryUserService.cs index 91576a1f..21e7e924 100644 --- a/AsbCloudInfrastructure/Services/TelemetryUserService.cs +++ b/AsbCloudInfrastructure/Services/TelemetryUserService.cs @@ -11,7 +11,7 @@ namespace AsbCloudInfrastructure.Services { private readonly IAsbCloudDbContext db; private readonly ITelemetryService telemetryService; - private readonly ICacheTable cacheTUsers; + private readonly CacheTable cacheTUsers; public TelemetryUserService(IAsbCloudDbContext db, CacheDb cacheDb, ITelemetryService telemetryService) { diff --git a/AsbCloudInfrastructure/Services/WellService.cs b/AsbCloudInfrastructure/Services/WellService.cs index cdacfe9c..f6956cf8 100644 --- a/AsbCloudInfrastructure/Services/WellService.cs +++ b/AsbCloudInfrastructure/Services/WellService.cs @@ -12,7 +12,7 @@ namespace AsbCloudInfrastructure.Services { private readonly IAsbCloudDbContext db; private readonly ITelemetryTracker telemetryTracker; - private readonly ICacheTable cacheWells; + private readonly CacheTable cacheWells; public WellService(IAsbCloudDbContext db, ITelemetryTracker telemetryTracker, CacheDb cacheDb) {