Sha256: 54f299bff1a2aa6b025f4f75ad92af39b32bf78b0a39a7703661f93d1740828b

Contents?: true

Size: 678 Bytes

Versions: 6817

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,817 entries across 6,815 versions & 24 rubygems

Version Path
mfk_openapi_ruby_client-1.0.0 vendor/bundle/ruby/2.7.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.54.15 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.53.79 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.53.17 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.53.3 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.53.1 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.52.121 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.52.92 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.52.79 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.52.5 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.52.0 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.51.93 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.51.38 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.51.37 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.51.34 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.51.22 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
typhoeus-1.4.0 lib/typhoeus/request/cacheable.rb