Sha256: ebffa9ea2131fec8be6b47d270b3ea2485152ef2d8ae3bab2c06e2247f3f6398

Contents?: true

Size: 913 Bytes

Versions: 1

Compression:

Stored size: 913 Bytes

Contents

# frozen_string_literal: true

require 'active_support/ordered_options'

module ActiveRemote
  module Cached
    class Railtie < ::Rails::Railtie
      config.active_remote_cached = ::ActiveSupport::OrderedOptions.new

      initializer 'active_remote-cached.initialize_cache' do |_app|
        config.active_remote_cached.expires_in ||= 5.minutes
        config.active_remote_cached.race_condition_ttl ||= 5.seconds

        ::ActiveRemote::Cached.cache(Rails.cache)

        ::ActiveRemote::Cached.cache.enable_nested_caching! if config.active_remote_cached.enable_nested_caching

        ::ActiveRemote::Cached.default_options(
          :expires_in => config.active_remote_cached.expires_in,
          :race_condition_ttl => config.active_remote_cached.race_condition_ttl
        )
      end

      ::ActiveSupport.on_load(:active_remote) do
        include ::ActiveRemote::Cached
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_remote-cached-1.1.1 lib/active_remote/cached/railtie.rb