Class: HttpThreshold::Cache
- Inherits:
-
Rack::Attack::Cache
- Object
- Rack::Attack::Cache
- HttpThreshold::Cache
- Defined in:
- lib/http_threshold/cache.rb
Instance Attribute Summary collapse
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Instance Method Summary collapse
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #read_count(unprefixed_key, period) ⇒ Object
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
6 7 8 9 |
# File 'lib/http_threshold/cache.rb', line 6 def initialize self.store = ::Rails.cache if defined?(::Rails.cache) @prefix = 'threshold' end |
Instance Attribute Details
#prefix ⇒ Object
Returns the value of attribute prefix.
4 5 6 |
# File 'lib/http_threshold/cache.rb', line 4 def prefix @prefix end |
Instance Method Details
#read_count(unprefixed_key, period) ⇒ Object
11 12 13 14 |
# File 'lib/http_threshold/cache.rb', line 11 def read_count(unprefixed_key, period) key, _ = key_and_expiry(unprefixed_key, period) store.read(key).to_i end |