mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-04 18:36:13 +02:00
Cache rubygems API response
This commit is contained in:
parent
176b7771bd
commit
321a310e95
@ -74,9 +74,12 @@ class Plugin
|
||||
def latest_version
|
||||
@latest_version ||=
|
||||
begin
|
||||
res = HTTPClient.get("https://rubygems.org/api/v1/versions/#{gem_name}.json")
|
||||
if res.code == 200
|
||||
JSON.parse(res.body).map {|ver| Gem::Version.new ver["number"] }.max.to_s
|
||||
url = "https://rubygems.org/api/v1/versions/#{gem_name}.json"
|
||||
Rails.cache.fetch(url, expires_in: 10.minutes) do # NOTE: 10.minutes could be changed if it doesn't fit
|
||||
res = HTTPClient.get(url)
|
||||
if res.code == 200
|
||||
JSON.parse(res.body).map {|ver| Gem::Version.new ver["number"] }.max.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
- @plugins.each do |plugin|
|
||||
/ TODO: make this page faster, such as do async, cache API response, etc
|
||||
/ TODO: make this page faster, such as do async, etc
|
||||
%p
|
||||
= plugin.gem_name
|
||||
- if plugin.installed?
|
||||
|
||||
@ -22,6 +22,8 @@ Rails.application.configure do
|
||||
# Raise an error on page load if there are pending migrations.
|
||||
config.active_record.migration_error = :page_load
|
||||
|
||||
config.cache_store = :memory_store, { size: 16 * 1024 * 1024 } # NOTE: `16.megabytes` will be undefined method error at here
|
||||
|
||||
# Debug mode disables concatenation and preprocessing of assets.
|
||||
# This option may cause significant delays in view rendering with a large
|
||||
# number of complex assets.
|
||||
|
||||
@ -36,8 +36,8 @@ Rails.application.configure do
|
||||
# Use a different logger for distributed setups.
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
# cache for rubygems.org response
|
||||
config.cache_store = :memory_store, { size: 16 * 1024 * 1024 } # NOTE: `16.megabytes` will be undefined method error at here
|
||||
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
|
||||
@ -19,6 +19,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
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user