修复 数据库循环清理功能不生效的异常:

1.单独提取数据库循环清理功能为Manager
2.原代码是初始化时判定一次,现改为数据库定期清理,配置后无需重启可生效
This commit is contained in:
SIC1016\caipeilun 2024-02-04 10:11:26 +08:00
parent 71d019a00b
commit dc031629ef
3 changed files with 11 additions and 7 deletions

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace Aitex.Core.RT.DBCore
{
public sealed class DataBaseCleaner
public class DataBaseCleanerManager
{
private List<string> tableNames = new List<string>();
@ -20,7 +20,15 @@ namespace Aitex.Core.RT.DBCore
private DateTime _dateDataKeepTo;
private PeriodicJob _monitorJob;
public void Initialize()
{
_monitorJob = new PeriodicJob(3600 * 1000 * 10, OnTimer, "CleanDataBase", true);
}
private bool OnTimer()
{
if (SC.GetValue<bool>("System.EnableDataBaseClean"))
{
@ -30,6 +38,7 @@ namespace Aitex.Core.RT.DBCore
CleanData();
}
return true;
}
public bool CleanData()

View File

@ -24,8 +24,6 @@ namespace Aitex.Core.RT.DBCore
private PeriodicJob _monitorJob;
private DataBaseCleaner _databaseCleaner = new DataBaseCleaner();
private FixSizeQueue<string> _sqlQueue = new FixSizeQueue<string>(1000);
public void Initialize()
@ -42,7 +40,6 @@ namespace Aitex.Core.RT.DBCore
_monitorJob = new PeriodicJob(100, Monitor,"DataBaseManager", true);
_databaseCleaner.Initialize();
}
/// <summary>
@ -361,8 +358,6 @@ namespace Aitex.Core.RT.DBCore
{
_monitorJob?.Stop();
_monitorJob = null;
_databaseCleaner?.Terminate();
}
/// <summary>

View File

@ -285,7 +285,7 @@
<Compile Include="Aitex\Core\RT\DataCollection\DataCollectionManager.cs" />
<Compile Include="Aitex\Core\RT\DataCollection\DefaultDataCollectionCallback.cs" />
<Compile Include="Aitex\Core\RT\DataCollection\IDataCollectionCallback.cs" />
<Compile Include="Aitex\Core\RT\DBCore\DataBaseCleaner.cs" />
<Compile Include="Aitex\Core\RT\DBCore\DataBaseCleanerManager.cs" />
<Compile Include="Aitex\Core\RT\DBCore\DataBaseManager.cs" />
<Compile Include="Aitex\Core\RT\DBCore\DB.cs" />
<Compile Include="Aitex\Core\RT\DBCore\IDataBase.cs" />