namespace HoneyBox.Core.Interfaces;

/// <summary>
/// 商品缓存服务接口
/// </summary>
public interface IGoodsCacheService
{
    /// <summary>
    /// 获取商品参与次数
    /// </summary>
    /// <param name="goodsId">商品ID</param>
    /// <returns>参与次数，如果缓存不存在返回-1</returns>
    Task<int> GetJoinCountAsync(int goodsId);

    /// <summary>
    /// 设置商品参与次数
    /// </summary>
    /// <param name="goodsId">商品ID</param>
    /// <param name="count">参与次数</param>
    Task SetJoinCountAsync(int goodsId, int count);

    /// <summary>
    /// 增加商品参与次数
    /// </summary>
    /// <param name="goodsId">商品ID</param>
    /// <returns>增加后的参与次数</returns>
    Task<int> IncrementJoinCountAsync(int goodsId);

    /// <summary>
    /// 清除商品缓存
    /// </summary>
    /// <param name="goodsId">商品ID</param>
    Task InvalidateGoodsCacheAsync(int goodsId);

    /// <summary>
    /// 获取商品列表缓存
    /// </summary>
    /// <param name="cacheKey">缓存键</param>
    /// <returns>缓存的商品列表JSON，如果不存在返回null</returns>
    Task<string?> GetGoodsListCacheAsync(string cacheKey);

    /// <summary>
    /// 设置商品列表缓存
    /// </summary>
    /// <param name="cacheKey">缓存键</param>
    /// <param name="data">商品列表JSON</param>
    /// <param name="expiry">过期时间</param>
    Task SetGoodsListCacheAsync(string cacheKey, string data, TimeSpan expiry);

    /// <summary>
    /// 获取商品详情缓存
    /// </summary>
    /// <param name="goodsId">商品ID</param>
    /// <param name="goodsNum">箱号</param>
    /// <returns>缓存的商品详情JSON，如果不存在返回null</returns>
    Task<string?> GetGoodsDetailCacheAsync(int goodsId, int goodsNum);

    /// <summary>
    /// 设置商品详情缓存
    /// </summary>
    /// <param name="goodsId">商品ID</param>
    /// <param name="goodsNum">箱号</param>
    /// <param name="data">商品详情JSON</param>
    /// <param name="expiry">过期时间</param>
    Task SetGoodsDetailCacheAsync(int goodsId, int goodsNum, string data, TimeSpan expiry);
}
