lib/lookup_by/cache.rb in lookup_by-0.8.0 vs lib/lookup_by/cache.rb in lookup_by-0.9.0

- old
+ new

@@ -31,11 +31,11 @@ when ::Integer raise ArgumentError, "`#{@klass}.lookup_by :#{@field}` options[:find] must be true when caching N" if @read == false @type = :lru @limit = options[:cache] - @cache = Rails.configuration.allow_concurrency ? Caching::SafeLRU.new(@limit) : Caching::LRU.new(@limit) + @cache = concurrent? ? Caching::SafeLRU.new(@limit) : Caching::LRU.new(@limit) @read = true @write ||= false @testing = true if Rails.env.test? && @write else @read = true @@ -128,9 +128,18 @@ @enabled = false clear end private + + def concurrent? + case Rails::VERSION::MAJOR + when 4 then Rails.configuration.cache_classes && Rails.configuration.eager_load + when 3 then Rails.configuration.allow_concurrency + else + true + end + end def primary_key?(value) case @primary_key_type when :integer value.is_a? Integer