コード例 #1
0
 public static void Setup(string @namespace = Constants.DefaultNamespace, Granularity[] granularities = null)
 {
     if (options == null && lazyConnector == null)
     {
         options       = new RateContext(@namespace, granularities ?? new Granularity[] { Granularity.Second, Granularity.Minute, Granularity.Hour, Granularity.Day });
         lazyConnector = new Lazy <RedisClient>(() => { return(RedisClientFactory.Connect("cache")); });
     }
 }
コード例 #2
0
        internal Counter(RedisClient redisConnection, IRateContext context)
        {
            if (redisConnection == null)
            {
                throw new ArgumentNullException("connectionProvider");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            this.redisConnection = redisConnection;
            this.context         = context;
            this.DB = this.redisConnection.GetDatabase();
        }
コード例 #3
0
        internal Limiter(RedisClient redisConnection, IRateContext context)
        {
            if (redisConnection == null)
            {
                throw new ArgumentNullException("connectionProvider");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            this.redisConnection = redisConnection;
            this.context         = context;
            this.DB       = this.redisConnection.GetDatabase();
            this.Interval = Granularity.Second.Ttl;
        }