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); } }