Class: IpFilter::Cache::Redis
- Inherits:
-
IpFilter::Cache
- Object
- IpFilter::Cache
- IpFilter::Cache::Redis
- Defined in:
- lib/ip_filter/cache/redis.rb
Instance Attribute Summary
Attributes inherited from IpFilter::Cache
Instance Method Summary collapse
-
#[](ip) ⇒ Object
Read from the Cache.
-
#[]=(ip, value) ⇒ Object
Write to the Cache.
- #reset ⇒ Object
Methods inherited from IpFilter::Cache
#initialize, #key_for, #serialize_output
Constructor Details
This class inherits a constructor from IpFilter::Cache
Instance Method Details
#[](ip) ⇒ Object
Read from the Cache.
13 14 15 16 17 |
# File 'lib/ip_filter/cache/redis.rb', line 13 def [](ip) value = store.get(key_for(ip)) # this method is inherited from IpFilter::Cache serialize_output(value) end |
#[]=(ip, value) ⇒ Object
Write to the Cache.
20 21 22 |
# File 'lib/ip_filter/cache/redis.rb', line 20 def []=(ip, value) store.set(key_for(ip), value.to_json) end |
#reset ⇒ Object
7 8 9 10 |
# File 'lib/ip_filter/cache/redis.rb', line 7 def reset keys = store.keys("#{@prefix}*") store.del keys unless keys.empty? end |