Ejemplo n.º 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")); });
     }
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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;
        }