def limit(key, count, duration)
      @key = key.to_s
      @duration = duration.to_i

      # :incr_count increases the hit count and simultaneously checks for breach
      if incr_count > count

        # :elapsed is the time window start Redis cache
        # If the time elapsed is less than window duration, the limit has been breached for the current window (return false).
        return false if @duration - elapsed > 0

        # Else reset the hit count to zero and window start time.
        reset
      end
      true
    end
def limit(key, count, duration)
      @key = key.to_s
      @duration = duration.to_i

      # :incr_count increases the hit count and simultaneously checks for breach
      if incr_count > count

        # :elapsed is the time window start Redis cache
        # If the time elapsed is less than window duration, the limit has been breached for the current window (return false).
        return false if @duration - elapsed > 0

        # Else reset the hit count to zero and window start time.
        reset
      end
      true
    end
Initializes and returns a Redis object.

 Requires params hash i.e.
 {
   :host => [String] (The hostname of the Redis server)
   :port => [String] (Numeric port number)
 }

 For further documentation refer to https://github.com/redis/redis-rb

 Any errors thrown are generated by the redis-rb client.

 @param [Hash] params
 @return [Redis]

 Registers a hit corresponding to the key specified, requires the max hit count and the duration to be passed.

 @param [String] key : Should be unique for one operation, can be added for multiple operations if a single rate
                       limiter is to be used for those operations.
 @param [Integer] count : Max rate limit count
 @param [Integer] duration : Duration of the time window.

 Count and duration params could change in each call and the limit breach value is returned corresponding to that.
 Ideally this method should be called with each param a constant on the application level.

 Returns false if the limit has been breached.
 Returns true if limit has not been breached. (duh)