Sha256: 4b45e432a73b286eb2c7e6fde64ceac00d3c212a7072f79e3a80e3eb7654daa2

Contents?: true

Size: 970 Bytes

Versions: 1

Compression:

Stored size: 970 Bytes

Contents

module Legion
  module Cache
    module Settings
      Legion::Settings.merge_settings(:cache, default) if Legion::Settings.method_defined? :merge_settings
      def self.default
        {
          driver: driver,
          servers: ['127.0.0.1:11211'],
          connected: false,
          enabled: true,
          namespace: 'legion',
          compress: false,
          failover: true,
          threadsafe: true,
          expires_in: 0,
          cache_nils: false,
          pool_size: 10,
          timeout: 5,
          serializer: Legion::JSON
        }
      end

      def self.driver(prefer = 'dalli')
        secondary = prefer == 'dalli' ? 'redis' : 'dalli'
        if Gem::Specification.find_all_by_name(prefer).count.positive?
          prefer
        elsif Gem::Specification.find_all_by_name(secondary).count.positive?
          secondary
        else
          raise NameError('Legion::Cache.driver is nil')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legion-cache-1.1.1 lib/legion/cache/settings.rb