mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
5.4 enabled caching in dev environment
This commit is contained in:
@@ -23,14 +23,14 @@ Rails.application.configure do
|
||||
config.action_controller.perform_caching = true
|
||||
config.action_controller.enable_fragment_cache_logging = true
|
||||
|
||||
config.cache_store = :memory_store
|
||||
config.cache_store = :file_store, "tmp/cache_store"
|
||||
config.public_file_server.headers = {
|
||||
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
||||
}
|
||||
else
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
config.cache_store = :null_store
|
||||
config.cache_store = :file_store, "tmp/cache_store"
|
||||
end
|
||||
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options).
|
||||
|
||||
@@ -25,7 +25,7 @@ Rails.application.configure do
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
config.cache_store = :null_store
|
||||
config.cache_store = :memory_store
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
class BeermappingApi
|
||||
def self.places_in(city)
|
||||
city = city.downcase
|
||||
Rails.cache.fetch(city, expires_in: 1.week) { get_places_in city }
|
||||
end
|
||||
|
||||
def self.get_places_in(city)
|
||||
url = "http://beermapping.com/webservice/loccity/#{key}/"
|
||||
response = HTTParty.get "#{url}#{ERB::Util.url_encode(city)}"
|
||||
|
||||
places = response.parsed_response["bmp_locations"]["location"]
|
||||
|
||||
return [] if places.is_a?(Hash) && places["id"].nil?
|
||||
|
||||
places = [places] if places.is_a?(Hash)
|
||||
|
||||
Reference in New Issue
Block a user