This commit is contained in:
mochaisvibecoded
2026-08-24 17:00:26 -04:00
parent cc1148050c
commit 42f7f57b72
401 changed files with 1108081 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Threading;
using LiteDB;
namespace Mocha2023.Classes.DBs
{
public static class LiteDbMaintenance
{
private static readonly TimeSpan Interval = TimeSpan.FromMinutes(2);
private static readonly List<Timer> ActiveTimers = new();
public static void StartPeriodicCheckpoint(string name, LiteDatabase database)
{
var timer = new Timer(_ =>
{
try
{
database.Checkpoint();
}
catch (Exception exception)
{
Console.WriteLine($"[LITEDB CHECKPOINT] {name} failed: {exception.Message}");
}
}, null, Interval, Interval);
lock (ActiveTimers)
ActiveTimers.Add(timer);
}
}
}