Sha256: 87c0dd3d7b9978a71cfd4b1e08dd5ed453993a00cedad6a687d7443087bf8e76
Contents?: true
Size: 836 Bytes
Versions: 23
Compression:
Stored size: 836 Bytes
Contents
module Opener class ChainedDaemon class LanguagesCache include MonitorMixin UPDATE_INTERVAL = (ENV['CACHE_EXPIRE_MINS']&.to_i || 5).minutes def initialize super #MonitorMixin @url = ENV['SUPPORTED_LANGUAGES_URL'] @cache = [] @last_updated = nil end def get synchronize do break @cache if @last_updated and @last_updated > UPDATE_INTERVAL.ago cache_update end end def cache_update puts "loading supported languages from url #{@url}" if ENV['DEBUG'] languages = SymMash.new JSON.parse ChainedDaemon.http.get(@url).body @last_updated = Time.now @cache = languages.data.each.with_object({}){ |l,h| h[l.code] = l } @cache end end end end
Version data entries
23 entries across 23 versions & 1 rubygems