Sha256: 21aae9e8c34e7e71c704e6a42e256a27df8964442ee94960dd88ecea97c6c65c

Contents?: true

Size: 617 Bytes

Versions: 13

Compression:

Stored size: 617 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 cacheable? && response = cache.get(self)
          response.cached = true
          finish(response)
        else
          super
        end
      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

13 entries across 12 versions & 4 rubygems

Version Path
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
talon_one-2.0.0 vendor/bundle/ruby/2.7.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.49.118 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.49.98 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.49.94 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.49.21 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.49.15 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.49.13 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.49.9 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
cloudsmith-api-0.44.4 vendor/bundle/ruby/2.3.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
approveapi-1.0.8 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
approveapi-1.0.5 vendor/bundle/ruby/2.6.0/gems/typhoeus-1.3.1/lib/typhoeus/request/cacheable.rb
typhoeus-1.3.1 lib/typhoeus/request/cacheable.rb