Class: Geocoder::Cache
- Inherits:
-
Object
- Object
- Geocoder::Cache
- Defined in:
- lib/geocoder/cache.rb
Instance Method Summary collapse
-
#[](url) ⇒ Object
Read from the Cache.
-
#[]=(url, value) ⇒ Object
Write to the Cache.
-
#expire(url) ⇒ Object
Expire cache entry for given URL, or pass
:all
to expire everything. -
#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/geocoder/cache.rb', line 4 def initialize(store, prefix) @store = store @prefix = prefix end |
Instance Method Details
#[](url) ⇒ Object
Read from the Cache.
12 13 14 |
# File 'lib/geocoder/cache.rb', line 12 def [](url) interpret store[key_for(url)] end |
#[]=(url, value) ⇒ Object
Write to the Cache.
19 20 21 |
# File 'lib/geocoder/cache.rb', line 19 def []=(url, value) store[key_for(url)] = value end |
#expire(url) ⇒ Object
Expire cache entry for given URL, or pass :all
to expire everything.
27 28 29 30 31 32 33 |
# File 'lib/geocoder/cache.rb', line 27 def expire(url) if url == :all urls.each{ |u| expire(u) } else self[url] = nil end end |