Module: RateLimit::Cache
- Defined in:
- lib/rate_limit/cache.rb
Class Method Summary collapse
Class Method Details
.clear(keys) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/rate_limit/cache.rb', line 27 def clear(keys) RateLimit.config.redis.multi do |redis| keys.each { |k| redis.del(k) } end rescue ::Redis::BaseError => e return true if RateLimit.config.fail_safe raise e end |
.read(key) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rate_limit/cache.rb', line 19 def read(key) RateLimit.config.redis.get(key) rescue ::Redis::BaseError => e return 0 if RateLimit.config.fail_safe raise e end |
.write(options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rate_limit/cache.rb', line 6 def write() RateLimit.config.redis.multi do |redis| .each do |key, value| redis.incr(key) redis.expire(key, value) end end rescue ::Redis::BaseError => e return true if RateLimit.config.fail_safe raise e end |