Sha256: 54f299bff1a2aa6b025f4f75ad92af39b32bf78b0a39a7703661f93d1740828b

Contents?: true

Size: 678 Bytes

Versions: 6772

Compression:

Stored size: 678 Bytes

Contents

module Typhoeus
  class Request
    module Cacheable
      def response=(response)
        cache.set(self, response) if cacheable? && !response.cached?
        super
      end

      def cacheable?
        cache
      end

      def run
        if response = cached_response
          response.cached = true
          finish(response)
        else
          super
        end
      end

      def cached_response
        cacheable? && cache.get(self)
      end

      def cache_ttl
        options[:cache_ttl]
      end

      private

      def cache
        return nil if options[:cache] === false
        options[:cache] || Typhoeus::Config.cache
      end
    end
  end
end

Version data entries

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

Version Path
cybrid_api_id_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_organization_ruby-0.123.117 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_bank_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_organization_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_id_ruby-0.123.116 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_bank_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_id_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_organization_ruby-0.123.115 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
ory-client-1.15.17 vendor/bundle/ruby/3.1.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_bank_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_organization_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_id_ruby-0.123.114 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_organization_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_bank_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_id_ruby-0.123.113 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_organization_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_bank_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_id_ruby-0.123.112 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_bank_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb
cybrid_api_organization_ruby-0.123.111 vendor/bundle/ruby/3.3.0/gems/typhoeus-1.4.1/lib/typhoeus/request/cacheable.rb