예제 #1
0
 public IRateManager Create(string name, RateLimitOptions options)
 {
     return(_cache.GetOrAdd(name, key =>
     {
         var store = _serviceProvider.GetRequiredService <IRateStore>();
         IRateManager manager = new RateManager(name, options, store);
         return manager;
     }));
 }
예제 #2
0
        public IRateManager Create(string name)
        {
            return(_cache.GetOrAdd(name, key =>
            {
                var options = _optionsMonitor.Get(name);
                if (options == null)
                {
                    throw new ArgumentException($"No RateLimitOptions named {name} found");
                }

                var store = _serviceProvider.GetRequiredService <IRateStore>();
                IRateManager manager = new RateManager(name, options, store);
                return manager;
            }));
        }