示例#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);
        }