Class: Gitlab::ApplicationRateLimiter::IncrementPerAction
- Inherits:
-
BaseStrategy
- Object
- BaseStrategy
- Gitlab::ApplicationRateLimiter::IncrementPerAction
- Defined in:
- lib/gitlab/application_rate_limiter/increment_per_action.rb
Instance Method Summary collapse
Instance Method Details
#increment(cache_key, expiry) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/gitlab/application_rate_limiter/increment_per_action.rb', line 6 def increment(cache_key, expiry) with_redis do |redis| redis.pipelined do |pipeline| pipeline.incr(cache_key) pipeline.expire(cache_key, expiry) end.first end end |
#read(cache_key) ⇒ Object
15 16 17 18 19 |
# File 'lib/gitlab/application_rate_limiter/increment_per_action.rb', line 15 def read(cache_key) with_redis do |redis| redis.get(cache_key).to_i end end |