Module: HTTPX::Plugins::ResponseCache::OptionsMethods

Defined in:
lib/httpx/plugins/response_cache.rb

Overview

adds support for the following options:

:supported_vary_headers

array of header values that will be considered for a “vary” header based cache validation (defaults to SUPPORTED_VARY_HEADERS).

:response_cache_store

object where cached responses are fetch from or stored in; defaults to :store (in-memory cache), can be set to :file_store (file system cache store) as well, or any object which abides by the Cache Store Interface

The Cache Store Interface requires implementation of the following methods:

  • #get(request) -> response or nil

  • #set(request, response) -> void

  • #clear() -> void)

Instance Method Summary collapse

Instance Method Details

#option_response_cache_store(value) ⇒ Object



70
71
72
73
74
75
76
77
78
79
# File 'lib/httpx/plugins/response_cache.rb', line 70

def option_response_cache_store(value)
  case value
  when :store
    Store.new
  when :file_store
    FileStore.new
  else
    value
  end
end

#option_supported_vary_headers(value) ⇒ Object



81
82
83
# File 'lib/httpx/plugins/response_cache.rb', line 81

def option_supported_vary_headers(value)
  Array(value).sort
end