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
ory-kratos-client-0.8.2.alpha1 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-client-0.0.1.alpha31 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-client-0.0.1.alpha30 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-client-0.0.1.alpha29 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-client-0.0.1.alpha28 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-client-0.0.1.alpha27 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-client-0.0.1.alpha24 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-client-0.0.1.alpha23 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-kratos-client-0.8.0.alpha2 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-client-0.0.1.alpha21 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-keto-client-0.7.0.alpha1 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-keto-client-0.7.0.alpha0 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-kratos-client-0.7.6.alpha7 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-kratos-client-0.7.6.alpha6 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-kratos-client-0.7.6.alpha5 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-kratos-client-0.7.6.alpha4 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-kratos-client-0.7.6.alpha3 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-kratos-client-0.7.6.alpha1 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
ory-kratos-client-0.7.5.alpha2 vendor/bundle/ruby/2.5.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.57.1 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus/request/cacheable.rb