Class: IpFilter::Cache::DalliStore
- Inherits:
-
IpFilter::Cache
- Object
- IpFilter::Cache
- IpFilter::Cache::DalliStore
- Defined in:
- lib/ip_filter/cache/dallistore.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
Clean Cache (not available, as DalliStore cannot iterate on cache).
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.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ip_filter/cache/dallistore.rb', line 11 def [](ip) result = case when store.respond_to?(:read) store.read key_for(ip) when store.respond_to?(:[]) store[key_for(ip)] when store.respond_to?(:get) store.get key_for(ip) end # this method is inherited from IpFilter::Cache serialize_output(result) end |
#[]=(ip, value) ⇒ Object
Write to the Cache.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ip_filter/cache/dallistore.rb', line 25 def []=(ip, value) case when store.respond_to?(:write) store.write key_for(ip), value when store.respond_to?(:[]=) store[key_for(ip)] = value when store.respond_to?(:set) store.set key_for(ip), value end end |
#reset ⇒ Object
Clean Cache (not available, as DalliStore cannot iterate on cache)
6 7 8 |
# File 'lib/ip_filter/cache/dallistore.rb', line 6 def reset logger.warning "Cannot reset ip_filter cache with DalliStore, you must reset all your cache manually." end |