Sha256: 3bba18a016896ad2422fdae2bfe30ca02ef7fa8aa8db34ef9924faa0c2ce36a1

Contents?: true

Size: 931 Bytes

Versions: 6772

Compression:

Stored size: 931 Bytes

Contents

module Typhoeus
  module Cache
    # This module provides a simple way to cache HTTP responses using Dalli.
    class Dalli
      # @example Set Dalli as the Typhoeus cache backend
      #   Typhoeus::Config.cache = Typhoeus::Cache::Dalli.new
      #
      # @param [ Dalli::Client ] client
      #   A connection to the cache server. Defaults to `Dalli::Client.new`
      # @param [ Hash ] options
      #   Options
      # @option options [ Integer ] :default_ttl
      #   The default TTL of cached responses in seconds, for requests which do not set a cache_ttl.
      def initialize(client = ::Dalli::Client.new, options = {})
        @client = client
        @default_ttl = options[:default_ttl]
      end

      def get(request)
        @client.get(request.cache_key)
      end

      def set(request, response)
        @client.set(request.cache_key, response, request.cache_ttl || @default_ttl)
      end
    end
  end
end

Version data entries

6,772 entries across 6,770 versions & 23 rubygems

Version Path
cybrid_api_bank_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_id_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_organization_ruby-0.123.149 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_bank_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_id_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_organization_ruby-0.123.148 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_bank_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_organization_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_id_ruby-0.123.147 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
ory-client-1.16.2 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
talon_one-7.0.0 .github/.example/vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_bank_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_organization_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_id_ruby-0.123.145 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_bank_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_id_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_organization_ruby-0.123.144 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
ory-client-1.16.1 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
ory-client-1.16.0 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb
cybrid_api_bank_ruby-0.123.143 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/cache/dalli.rb