Add automatic MessageCache cleanup on startup

This commit is contained in:
Noikoio 2019-03-08 18:53:57 -08:00
parent 230654f52e
commit 1186ba1109

View file

@ -278,6 +278,14 @@ namespace Noikoio.RegexBot.Module.ModLogs
+ ")";
c.ExecuteNonQuery();
}
// For lack of an automated mechanism, delete old messages on startup here.
using (var c = db.CreateCommand())
{
c.CommandText = "DELETE FROM " + TableMessage + " WHERE " +
"coalesce(edited_ts, created_ts) < (now() - interval '90 days')";
c.ExecuteNonQuery();
}
}
}