lib/tml/cache.rb
def warmup_from_files(version = nil, cache_path = nil)
      t0 = Time.now
      Tml.logger = Logger.new(STDOUT)

      Tml.logger.debug('Starting cache warmup from local files...')
      version ||= Tml.config.cache[:version]
      cache_path ||= Tml.config.cache[:path]
      cache_path = "#{cache_path}/#{version}"

      Tml.cache.version.set(version.to_s)
      Tml.logger.debug("Warming Up Version: #{Tml.cache.version}")

      application = JSON.parse(File.read("#{cache_path}/application.json"))
      Tml.cache.store(Tml::Application.cache_key, application)

      sources = JSON.parse(File.read("#{cache_path}/sources.json"))

      application['languages'].each do |lang|
        locale = lang['locale']

        language = JSON.parse(File.read("#{cache_path}/#{locale}/language.json"))
        Tml.cache.store(Tml::Language.cache_key(locale), language)

        sources.each do |src|
          source = JSON.parse(File.read("#{cache_path}/#{locale}/sources/#{src}.json"))
          Tml.cache.store(Tml::Source.cache_key(locale, src), source)
        end
      end

      t1 = Time.now
      Tml.logger.debug("Cache warmup took #{t1-t0}s")
    end
def warmup_from_files(version = nil, cache_path = nil)
      t0 = Time.now
      Tml.logger = Logger.new(STDOUT)

      Tml.logger.debug('Starting cache warmup from local files...')
      version ||= Tml.config.cache[:version]
      cache_path ||= Tml.config.cache[:path]
      cache_path = "#{cache_path}/#{version}"

      Tml.cache.version.set(version.to_s)
      Tml.logger.debug("Warming Up Version: #{Tml.cache.version}")

      application = JSON.parse(File.read("#{cache_path}/application.json"))
      Tml.cache.store(Tml::Application.cache_key, application)

      sources = JSON.parse(File.read("#{cache_path}/sources.json"))

      application['languages'].each do |lang|
        locale = lang['locale']

        language = JSON.parse(File.read("#{cache_path}/#{locale}/language.json"))
        Tml.cache.store(Tml::Language.cache_key(locale), language)

        sources.each do |src|
          source = JSON.parse(File.read("#{cache_path}/#{locale}/sources/#{src}.json"))
          Tml.cache.store(Tml::Source.cache_key(locale, src), source)
        end
      end

      t1 = Time.now
      Tml.logger.debug("Cache warmup took #{t1-t0}s")
    end
Warms up cache from local files