초기커밋
This commit is contained in:
71
BrokerApiTest/Helper/DocRepo/PlanetInfoCache.cs
Normal file
71
BrokerApiTest/Helper/DocRepo/PlanetInfoCache.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
// 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<PlanetInfo> m_planets = [];
|
||||
// private readonly IServiceScopeFactory m_scope_factory;
|
||||
//
|
||||
// public PlanetInfoCache(IServiceScopeFactory scopeFactory, IHostApplicationLifetime lifetime)
|
||||
// {
|
||||
// m_scope_factory = scopeFactory;
|
||||
// }
|
||||
//
|
||||
// public IEnumerable<PlanetInfo> 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<PlanetInfoRepo>();
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user