#nullable enable
namespace Baya.Application.Contracts.Common;

/// <summary>
/// Typed caching seam for read-heavy and reference data. The mock is backed by in-process memory; the
/// real implementation swaps to Redis while keeping the same key/TTL scheme.
/// </summary>
public interface ICacheService
{
    ValueTask<T?> GetAsync<T>(string key, CancellationToken cancellationToken = default);

    ValueTask SetAsync<T>(string key, T value, TimeSpan? ttl = null, CancellationToken cancellationToken = default);

    ValueTask RemoveAsync(string key, CancellationToken cancellationToken = default);

    ValueTask<T> GetOrCreateAsync<T>(
        string key,
        Func<CancellationToken, ValueTask<T>> factory,
        TimeSpan? ttl = null,
        CancellationToken cancellationToken = default);
}
