Class: USPSStandardizer::Cache
- Inherits:
-
Object
- Object
- USPSStandardizer::Cache
- Defined in:
- lib/usps_standardizer/cache.rb
Instance Method Summary collapse
- #[](url) ⇒ Object
- #[]=(url, value) ⇒ Object
- #expire(url) ⇒ Object
-
#initialize(store, prefix) ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize(store, prefix) ⇒ Cache
Returns a new instance of Cache.
4 5 6 7 |
# File 'lib/usps_standardizer/cache.rb', line 4 def initialize(store, prefix) @store = store @prefix = prefix end |
Instance Method Details
#[](url) ⇒ Object
9 10 11 |
# File 'lib/usps_standardizer/cache.rb', line 9 def [](url) interpret store[key_for(url)] end |
#[]=(url, value) ⇒ Object
13 14 15 |
# File 'lib/usps_standardizer/cache.rb', line 13 def []=(url, value) store[key_for(url)] = value end |
#expire(url) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/usps_standardizer/cache.rb', line 17 def expire(url) if url == :all urls.each{ |u| expire(u) } else expire_single_url(url) end end |