Optimize action log flushing

This commit is contained in:
2025-05-18 12:00:05 +08:00
parent c597df3937
commit fdfdffa382
5 changed files with 95 additions and 37 deletions

View File

@ -0,0 +1,15 @@
using DysonNetwork.Sphere.Account;
using EFCore.BulkExtensions;
namespace DysonNetwork.Sphere.Storage.Handlers;
public class ActionLogFlushHandler(IServiceProvider serviceProvider) : IFlushHandler<ActionLog>
{
public async Task FlushAsync(IReadOnlyList<ActionLog> items)
{
using var scope = serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDatabase>();
await db.BulkInsertAsync(items);
}
}