Do not save cache of rates in the database (#6978)

We were previously saving the rates in the database in a JSONB blob
column. However, the volume of data ise consequential enough for
provoking timeouts during update.

Due to how postgres works, this also create bloat in the database that
isn't cleaned immediately.

This PR fixes this issue by saving the cache in files instead.
This commit is contained in:
Nicolas Dorier
2025-11-05 16:54:34 +09:00
committed by GitHub
parent 1411745265
commit 849b27cf49
3 changed files with 56 additions and 77 deletions

View File

@@ -38,6 +38,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using NBitcoin;
using NBitcoin.Payment;
using NBitcoin.RPC;
@@ -448,7 +449,7 @@ namespace BTCPayServer
public static IServiceCollection AddScheduledTask<T>(this IServiceCollection services, TimeSpan every)
where T : class, IPeriodicTask
{
services.AddSingleton<T>();
services.TryAddSingleton<T>();
services.AddTransient<ScheduledTask>(o => new ScheduledTask(typeof(T), every));
return services;
}