// namespace BrokerCore.Repository; // // using DbEntity; // // using Microsoft.Extensions.DependencyInjection; // using Microsoft.Extensions.Hosting; // // using ServerCommon; // // using ServerCore; using ServerBase; // // //================================================== // // 행성 정보 캐시를 갱신한다. // //================================================== // public class PlanetInfoCache : BackgroundService // { // private readonly object m_lock = new(); // private IEnumerable m_planets = []; // private readonly IServiceScopeFactory m_scope_factory; // // public PlanetInfoCache(IServiceScopeFactory scopeFactory, IHostApplicationLifetime lifetime) // { // m_scope_factory = scopeFactory; // } // // public IEnumerable Planets // { // get // { // lock (m_planets) // { // return m_planets; // } // } // } // // protected override async Task ExecuteAsync(CancellationToken stoppingToken) // { // while (!stoppingToken.IsCancellationRequested) // { // try // { // await updateData(); // } // catch (Exception e) // { // Console.WriteLine(e); // throw; // } // // await Task.Delay(TimeSpan.FromSeconds(120), stoppingToken); // 120초마다 데이터 갱신 // } // } // // private async Task updateData() // { // using var scope = m_scope_factory.CreateScope(); // var planet_info_repo = scope.ServiceProvider.GetRequiredService(); // var (result, planet_infos) = await planet_info_repo.findAll(); // if (result.isFail() || planet_infos == null) // { // Log.getLogger().error("Failed to find planet infos"); // return; // } // // lock (m_lock) // { // m_planets = planet_infos; // } // } // }