Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyhhssyy committed Jun 3, 2024
1 parent 21926fd commit c934ef7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions AmiyaBotPlayerRatingServer/Data/ArknightsMemoryCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public ArknightsMemoryCache(IMemoryCache memoryCache,ILogger<ArknightsMemoryCach
try
{
InitializeAssets();
UpdateCache();
}
catch (Exception ex)
{
Expand All @@ -99,9 +100,6 @@ public ArknightsMemoryCache(IMemoryCache memoryCache,ILogger<ArknightsMemoryCach
});

//不可以用Hangfire,因为每个服务器都会有一个实例
_ = new Timer(UpdateCache, null, TimeSpan.Zero, TimeSpan.FromHours(1));
UpdateCache(null);
}

private void InitializeAssets()
Expand Down Expand Up @@ -183,7 +181,7 @@ public void UpdateAssets()
ExtractGameData();
}

private void UpdateCache(object? state)
private void UpdateCache()
{
//遍历gamedata/excel目录下的所有json文件
Directory.GetFiles(Path.Combine(_directoryPath, "gamedata/excel")).ToList().ForEach(file =>
Expand All @@ -195,7 +193,7 @@ private void UpdateCache(object? state)
}
});

Directory.GetFiles(Path.Combine(_directoryPath, "gamedata/indexes")).ToList().ForEach(file =>
Directory.GetFiles(Path.Combine(_directoryPath, "indexes")).ToList().ForEach(file =>
{
var fileName = Path.GetFileName(file);
if (fileName.EndsWith(".json"))
Expand Down

0 comments on commit c934ef7

Please sign in to comment.