public Task ResetDuplicateCheckAsync() { _counter = Interlocked.Exchange(ref _counter, 0); _bloomFilter.Clear(); _bloomFilter = new BloomFilter(_options.FalsePositiveProbability, _options.ExpectedInsertions); return(Task.CompletedTask); }
/// <summary> /// /// </summary> /// <param name="blockBaseOn"> 判断不同用户的claim,建议使用ip</param> /// <param name="resetMs">重设所有请求为0的间隔,毫秒单位</param> /// <param name="blockTimeMs">黑名单持续时间,毫秒单位</param> public LimFxRateLimitHandler(string blockBaseOn = ClaimTypes.UserData, double resetMs = 1000, double blockTimeMs = 1000) { resettimer = new Timer(); resettimer.Interval = resetMs; resettimer.Elapsed += (s, e) => requesterInfos.Clear(); unBlocTimer = new Timer(blockTimeMs); this.blockBaseOn = blockBaseOn; unBlocTimer.Elapsed += (s, e) => blackList.Clear(); resettimer.Start(); unBlocTimer.Start(); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { _bloomFilter.Clear(); }
static void ResetBlackList(object sender, ElapsedEventArgs e) { blackList.Clear(); }
/// <summary> /// Reset duplicate check. /// </summary> public void ResetDuplicateCheck() { _counter = Interlocked.Exchange(ref _counter, 0); _bloomFilter.Clear(); _bloomFilter = new BloomFilter(_options.FalsePositiveProbability, _options.ExpectedInsertions); }