using JiShe.CollectBus.IoTDBProvider.Interface; using Microsoft.Extensions.Options; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace JiShe.CollectBus.IoTDBProvider.Provider { /// /// 实现带缓存的Session工厂 /// public class IoTDBSessionFactory : IIoTDBSessionFactory { private readonly IoTDBOptions _options; private readonly ConcurrentDictionary _pools = new(); public IoTDBSessionFactory(IOptions options) { _options = options.Value; } public IIoTDBSessionPool GetSessionPool(bool useTableSession) { return _pools.GetOrAdd(useTableSession, key => { return key ? new TableSessionPoolAdapter(_options) : new SessionPoolAdapter(_options); }); } } }