Ejemplo n.º 1
0
        public ValueTask RemoveAsync(ThrottlerItem throttlerItem, CancellationToken cancellationToken)
        {
            var key = throttlerItem.GenerateCounterKey();

            _cache.Remove(key);
            return(new ValueTask());
        }
Ejemplo n.º 2
0
        public ValueTask SetAsync(ThrottlerItem throttlerItem, Counter counter, TimeSpan?expirationTime, CancellationToken cancellationToken)
        {
            var key = throttlerItem.GenerateCounterKey();

            _cache[key] = counter;
            return(new ValueTask());
        }
Ejemplo n.º 3
0
        public ValueTask <Counter?> GetAsync(ThrottlerItem throttlerItem, CancellationToken cancellationToken)
        {
            var key = throttlerItem.GenerateCounterKey();

            if (_cache.TryGetValue(key, out var counter))
            {
                return(new ValueTask <Counter?>(counter));
            }
            else
            {
                return(new ValueTask <Counter?>(default(Counter?)));
            }
        }