// Copyright (c) 2023 bradson // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. using System.Threading.Tasks; namespace PerformanceFish.Cache; public interface ICacheKeyable { [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetHashCode(); } public interface IMemberCount { public T1 First { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; [MethodImpl(MethodImplOptions.AggressiveInlining)] set; } } public interface IMemberCount : IMemberCount { public T2 Second { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; [MethodImpl(MethodImplOptions.AggressiveInlining)] set; } } public interface IMemberCount : IMemberCount { public T3 Third { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; [MethodImpl(MethodImplOptions.AggressiveInlining)] set; } } public interface IMemberCount : IMemberCount { public T4 Fourth { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; [MethodImpl(MethodImplOptions.AggressiveInlining)] set; } } public interface IInitializable : IMemberCount { [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Initialize(T key); } public interface IInitializable : IMemberCount { [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Initialize(T1 first, T2 second); } public interface IInitializable : IMemberCount { [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Initialize(T1 first, T2 second, T3 third); } public interface IInitializable : IMemberCount { [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Initialize(T1 first, T2 second, T3 third, T4 fourth); } public interface IDirtyable { public bool Dirty { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; } } public interface ICacheable : IDirtyable { public void Update(ref TKey key); } public interface ICacheable : IDirtyable { public void Update(ref TKey key, T2 second); } public interface ICacheable : IDirtyable { public void Update(ref TKey key, T2 second, T3 third); } public interface IAsyncCacheable : IDirtyable { public Task? Task { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; [MethodImpl(MethodImplOptions.AggressiveInlining)] set; } public TResult? Result { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; [MethodImpl(MethodImplOptions.AggressiveInlining)] set; } } public interface IAsyncCacheable : IAsyncCacheable { public TResult? MakeResultAsync(TKey key); } public interface IAsyncCacheable : IAsyncCacheable { public ValueTask MakeResultAsync(TKey key, T2 second); } internal sealed record Countdown(int Value) { public volatile int Value = Value; }