using Application.Abstractions.Messaging;
using Application.Abstractions.Cache;

namespace Application.Features.Api.Crypto.Orderbook.GetLive;

public sealed class Handler(ICacheService cache) : IQueryHandler<Query, Response>
{
    public async Task<Response> Handle(Query request, CancellationToken ct)
    {
        var cacheKey = CacheKeys.CryptoOrderbookLive(request.Market);

        var cached = await cache.GetAsync<Response>(cacheKey, ct);

        return cached ?? new Response(0, 0, [], 0, 0, "");
    }
}