Class: Studio::Geo::Lookup::RailsCache
- Inherits:
-
Object
- Object
- Studio::Geo::Lookup::RailsCache
- Defined in:
- lib/studio/geo/lookup.rb
Overview
Adapts Rails.cache to the []/[]= duck Geocoder's Generic cache store expects, adding the TTL that Rails.cache.write supports and Geocoder never passes.
Instance Method Summary collapse
- #[](url) ⇒ Object
- #[]=(url, value) ⇒ Object
-
#initialize(ttl: 86_400) ⇒ RailsCache
constructor
A new instance of RailsCache.
Constructor Details
#initialize(ttl: 86_400) ⇒ RailsCache
Returns a new instance of RailsCache.
34 35 36 |
# File 'lib/studio/geo/lookup.rb', line 34 def initialize(ttl: 86_400) @ttl = ttl end |
Instance Method Details
#[](url) ⇒ Object
38 39 40 |
# File 'lib/studio/geo/lookup.rb', line 38 def [](url) ::Rails.cache.read(url) end |
#[]=(url, value) ⇒ Object
42 43 44 |
# File 'lib/studio/geo/lookup.rb', line 42 def []=(url, value) ::Rails.cache.write(url, value, expires_in: @ttl) end |