Sha256: f06ca7cdbda6021f4420b1d0df06d70a1910e64fabf0d8e7c38b34c48068faca
Contents?: true
Size: 881 Bytes
Versions: 20
Compression:
Stored size: 881 Bytes
Contents
module Typhoeus module Cache # This module provides a simple way to cache HTTP responses in using the Rails cache. class Rails # @example Use the Rails cache setup to cache Typhoeus responses. # Typhoeus::Config.cache = Typhoeus::Cache::Rails.new # # @param [ ActiveSupport::Cache::Store ] cache # A Rails cache backend. Defaults to Rails.cache. # @param [ Integer ] default_ttl # The default TTL of cached responses in seconds, for requests which do not set a cache_ttl. def initialize(cache = ::Rails.cache, options = {}) @cache = cache @default_ttl = options[:default_ttl] end def get(request) @cache.read(request) end def set(request, response) @cache.write(request, response, :expires_in => request.cache_ttl || @default_ttl) end end end end
Version data entries
20 entries across 19 versions & 6 rubygems