Sha256: c04d726493124fe5e8c4a04943ed4e1a9c6f367c30b687b083354b61a2fc2961

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
module AnyCache::Adapters
  require_relative 'adapters/basic'
  require_relative 'adapters/delegator'
  require_relative 'adapters/dalli'
  require_relative 'adapters/redis'
  require_relative 'adapters/redis_store'
  require_relative 'adapters/active_support_naive_store'
  require_relative 'adapters/active_support_file_store'
  require_relative 'adapters/active_support_redis_cache_store'
  require_relative 'adapters/active_support_memory_store'

  class << self
    # @param driver [Object]
    # @return [AnyCache::Adapters::Basic]
    #
    # @raise [AnyCache::UnsupportedCacheDriverError]
    #
    # @api private
    # @since 0.1.0
    # rubocop:disable Metrics/LineLength
    def build(driver)
      case
      when RedisStore.supported_driver?(driver)                   then RedisStore.new(driver)
      when Redis.supported_driver?(driver)                        then Redis.new(driver)
      when Dalli.supported_driver?(driver)                        then Dalli.new(driver)
      when ActiveSupportRedisCacheStore.supported_driver?(driver) then ActiveSupportRedisCacheStore.new(driver)
      when ActiveSupportMemoryStore.supported_driver?(driver)     then ActiveSupportMemoryStore.new(driver)
      when ActiveSupportFileStore.supported_driver?(driver)       then ActiveSupportFileStore.new(driver)
      when Delegator.supported_driver?(driver)                    then Delegator.new(driver)
      else
        raise AnyCache::UnsupportedCacheDriverError
      end
    end
    # rubocop:enable Metrics/LineLength
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
any_cache-0.1.0 lib/any_cache/adapters.rb