Skip to content
Snippets Groups Projects
Commit bca36899 authored by Stan Hu's avatar Stan Hu Committed by Rémy Coutable
Browse files

Cache the last usage data to avoid unicorn timeouts

parent c53afeda
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -15,7 +15,7 @@ class GitlabUsagePingWorker
 
begin
HTTParty.post(url,
body: Gitlab::UsageData.to_json,
body: Gitlab::UsageData.to_json(true),
headers: { 'Content-type' => 'application/json' }
)
rescue HTTParty::Error => e
Loading
Loading
Loading
Loading
@@ -3,16 +3,16 @@ module Gitlab
include Gitlab::CurrentSettings
 
class << self
def data
Rails.cache.fetch('usage_data', expires_in: 1.hour) { uncached_data }
def data(force_refresh = false)
Rails.cache.fetch('usage_data', force: force_refresh) { uncached_data }
end
 
def uncached_data
license_usage_data.merge(system_usage_data)
end
 
def to_json
data.to_json
def to_json(force_refresh = false)
data(force_refresh).to_json
end
 
def system_usage_data
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment