/// <summary> /// Default Cotr. /// </summary> /// <param name="config">Cache config</param> /// <param name="logger">Logger</param> /// <param name="connectionGenerator">Accepts ConnectionType (first argument) and /// ConnectionString (second argument) as input and returns an instance of DB connection (Must NOT be Opened). /// <para>Both ConnectionType and ConnectionString are exactly what mentioned in DbProfile Config.</para></param> public AsyncCacheMgr(IAsyncCacheConfig config, ILog logger, Func <string, string, DbConnection> connectionGenerator) { config.ThrowIfNull($"{nameof(AsyncCacheMgr)}.{nameof(config)}"); logger.ThrowIfNull($"{nameof(AsyncCacheMgr)}.{nameof(logger)}"); connectionGenerator.ThrowIfNull($"{nameof(AsyncCacheMgr)}.{nameof(connectionGenerator)}"); config.Validate(); _maxConcurrency = StaticCalls.AdjustMaxConcurrency(config.MaxConcurrency); var connectionBlocker = new BlockingCollection <string>(_maxConcurrency); for (var i = 0; i < _maxConcurrency; i++) { connectionBlocker.Add("DB" + i); } _cacheProfiles = config.CacheProfiles.Validate(); _initInputBuilder = new InitInputBuilder { DatabaseProfiles = config.DbProfiles.Validate(), ReloadProfiles = config.ReloadProfiles.Validate(), SerializationProfiles = config.SerializationProfiles.Validate(), LocalCacheFolder = config.CacheLocalFolder.ToDirectoryInfo(), ConnectionBlocker = connectionBlocker, ConnectionGenerator = connectionGenerator, Logger = logger, Token = _cts.Token }; _cacheCollection = new ConcurrentQueue <IAsyncCache>(); _cacheDictionary = new ConcurrentDictionary <Type, object>(); }
private AsyncCacheData <TKey, TValue> CreateCacheDataInstance(ICacheConfigProfile config, ICacheDataSerializer serializer) { var partitions = StaticCalls.AdjustPartitionCount(config.PartitionCount); if (!config.KeyIsValue) { return(new DictionaryCacheData <TKey, TValue>(partitions, _keyComparer, serializer)); } if (typeof(TKey) == typeof(TValue)) { return(new HashSetCacheData <TKey>(partitions, _keyComparer, serializer) as AsyncCacheData <TKey, TValue>); } throw new AsyncCacheException(AsyncCacheErrorCode.InvalidConfig, $"Config sets {nameof(config.KeyIsValue)} = true. But TKey and TValue not same type."); }
protected void del_Click(object sender, EventArgs e) { StaticCalls.DeleteProperties(); }
protected void images_Click(object sender, EventArgs e) { StaticCalls.Move_Images(); }