using System;
using System.Collections.Generic;

namespace Shop.Infrastructure;

public sealed class PriceCache
{
    private readonly object _gate = new();
    private readonly Dictionary<string, decimal> _prices = new();

    public bool TryGet(string sku, out decimal price)
    {
        lock (_gate)
        {
            return _prices.TryGetValue(sku, out price);
        }
    }

    public void Set(string sku, decimal price)
    {
        lock (_gate)
        {
            _prices[sku] = price;
        }
    }
}
