Sha256: 98e945884ddaae74246dc519162f26324cffa61b2ef56d1a45d8bea5e0f47e2f

Contents?: true

Size: 665 Bytes

Versions: 8

Compression:

Stored size: 665 Bytes

Contents

# frozen_string_literal: true

require 'seo_cache/page_caching'
require 'seo_cache/page_render'

module SeoCache
  class PopulateCache
    def initialize(host, paths, options = {})
      @host         = host
      @paths        = paths
      @page_render  = PageRender.new
      @page_caching = PageCaching.new

      @force_cache = options.fetch(:force_cache, false)
    end

    def perform
      @paths.each do |path|
        next if @page_caching.cache_exists?(path) && !@force_cache

        page_source = @page_render.persistent_get(@host + path)
        @page_caching.cache(page_source, path)
      end

      @page_render.close_connection
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
seo_cache-0.8.0 lib/seo_cache/populate_cache.rb
seo_cache-0.7.0 lib/seo_cache/populate_cache.rb
seo_cache-0.6.0 lib/seo_cache/populate_cache.rb
seo_cache-0.5.0 lib/seo_cache/populate_cache.rb
seo_cache-0.4.0 lib/seo_cache/populate_cache.rb
seo_cache-0.3.0 lib/seo_cache/populate_cache.rb
seo_cache-0.2.0 lib/seo_cache/populate_cache.rb
seo_cache-0.1.0 lib/seo_cache/populate_cache.rb