Exemplo n.º 1
0
        /// <summary>
        /// Checks if over throttle limit
        /// </summary>
        /// <returns>True if under throttle limit, false otherwise</returns>
        public bool Check()
        {
            var hit = LocalCache.TryGet <HitInfo>(this.CacheKey);

            if (hit == null)
            {
                hit = new HitInfo {
                    Counter = 1
                };
                LocalCache.Add(this.CacheKey, hit, this.Duration);
            }
            else
            {
                if (hit.Counter++ >= this.Limit)
                {
                    return(false);
                }
            }

            return(true);
        }