Ejemplo n.º 1
0
        public static ThrottlerItem Get(ThrottlerItem throttlerItem)
        {
            if (throttlerItem == null)
            {
                return(default(ThrottlerItem));
            }


            var key = throttlerItem.GenerateKey();

            if (_cache.TryGetValue(key, out ThrottlerItem stored))
            {
                return(stored);
            }

            return(throttlerItem);
        }
Ejemplo n.º 2
0
        public static void Set(ThrottlerItem throttlerItem)
        {
            var key = throttlerItem.GenerateKey();

            _cache.AddOrUpdate(key, throttlerItem, (key, oldValue) => oldValue = throttlerItem);
        }
Ejemplo n.º 3
0
        public static void Remove(ThrottlerItem throttlerItem)
        {
            var key = throttlerItem.GenerateKey();

            _cache.TryRemove(key, out ThrottlerItem stored);
        }