using OneOf; using OneOf.Types; namespace NadekoBot.Common; public interface IBotCache { /// /// Adds an item to the cache /// /// Key to add /// Value to add to the cache /// Optional expiry /// Whether old value should be overwritten /// Type of the value /// Returns whether add was sucessful. Always true unless ovewrite = false ValueTask AddAsync(TypedKey key, T value, TimeSpan? expiry = null, bool overwrite = true); /// /// Get an element from the cache /// /// Key /// Type of the value /// Either a value or ValueTask> GetAsync(TypedKey key); /// /// Remove a key from the cache /// /// Key to remove /// Type of the value /// Whether there was item ValueTask RemoveAsync(TypedKey key); /// /// Get the key if it exists or add a new one /// /// Key to get and potentially add /// Value creation factory /// Optional expiry /// Type of the value /// The retrieved or newly added value ValueTask GetOrAddAsync( TypedKey key, Func> createFactory, TimeSpan? expiry = null); }