修复流水号缓存服务的并行错误;
修复输出线程没有捕获异常的严重错误;
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
@@ -11,7 +12,7 @@ namespace MesETL.App.Services.Seq;
|
||||
public class SeqService
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
private readonly Dictionary<SeqConfig, long> _cachedSequence;
|
||||
private readonly ConcurrentDictionary<SeqConfig, long> _cachedSequence;
|
||||
|
||||
public IReadOnlyDictionary<SeqConfig, long> CachedSequence => _cachedSequence;
|
||||
|
||||
@@ -24,7 +25,7 @@ public class SeqService
|
||||
};
|
||||
_connectionString = builder.ConnectionString;
|
||||
|
||||
_cachedSequence = new Dictionary<SeqConfig, long>();
|
||||
_cachedSequence = new ConcurrentDictionary<SeqConfig, long>();
|
||||
}
|
||||
|
||||
private async Task<long> UpdateSequenceID(string name,int step,long max,bool recycle, int add)
|
||||
@@ -99,9 +100,9 @@ public class SeqService
|
||||
/// 移除一个缓存的流水号
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
public void RemoveCachedSeq(SeqConfig config)
|
||||
public bool RemoveCachedSeq(SeqConfig config)
|
||||
{
|
||||
_cachedSequence.Remove(config);
|
||||
return _cachedSequence.Remove(config, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user