using System.Collections.Immutable; namespace Connected.Caching; public delegate void CacheInvalidateHandler(CacheEventArgs e); public interface ICache : IDisposable { event CacheInvalidateHandler? Invalidating; event CacheInvalidateHandler? Invalidated; ImmutableList? All(string key); Task Get(string key, object id, Func>? retrieve); T? Get(string key, object id); IEntry? Get(string key, object id); Task Get(string key, Func predicate, Func>? retrieve); T? Get(string key, Func predicate); T? First(string key); IEnumerator? GetEnumerator(string key); ImmutableList? Where(string key, Func predicate); bool Exists(string key); bool IsEmpty(string key); void CreateKey(string key); Task Clear(string key); T? Set(string key, object id, T? instance); T? Set(string key, object id, T? instance, TimeSpan duration); T? Set(string key, object id, T? instance, TimeSpan duration, bool slidingExpiration); void CopyTo(string key, object id, IEntry entry); Task?> Remove(string key, Func predicate); Task Remove(string key, object id); Task Invalidate(string key, object id); int Count(string key); bool Any(string key); ImmutableList? Keys(string key); ImmutableList? Keys(); }