question 366 Profiling & Optimization · medium
Fix the converter that ignores new rates
Prices are converted with cached exchange rates. When finance updates a rate with set_rate, conversions keep using the old rate until the server restarts. Fix it so a conversion after set_rate uses the new rate, while repeated conversions between updates are still cached.
Functions
set_rate(currency, rate) updates the rate table; convert(amount, currency) returns amount * rateRuleafter
set_rate, conversions use the new rate; between updates, repeated conversions of the same amount are cached