예제 #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);
        }
예제 #2
0
        public static void Set(ThrottlerItem throttlerItem)
        {
            var key = throttlerItem.GenerateKey();

            _cache.AddOrUpdate(key, throttlerItem, (key, oldValue) => oldValue = throttlerItem);
        }
예제 #3
0
        public static void Remove(ThrottlerItem throttlerItem)
        {
            var key = throttlerItem.GenerateKey();

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