Class: Faraday::EdsCachingMiddleware

Inherits:
Middleware
  • Object
show all
Defined in:
lib/faraday/eds_caching_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, *args) ⇒ EdsCachingMiddleware

Returns a new instance of EdsCachingMiddleware.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/faraday/eds_caching_middleware.rb', line 9

def initialize(app, *args)
  super(app)
  options = args.first || {}
  @auth_expire            = options.fetch(:auth_expire, 1500)
  @info_expire            = options.fetch(:info_expire, 86400)
  @retrieve_expire        = options.fetch(:retrieve_expire, 1800)
  @search_expire          = options.fetch(:search_expire, 1800)
  @export_format_expire   = options.fetch(:export_format_expire, 86400)
  @citation_styles_expire = options.fetch(:citation_styles_expire, 86400)
  @logger                 = options.fetch(:logger, nil)
  @namespace              = options.fetch(:namespace, 'faraday-eds-cache')
  @store                  = options.fetch(:store, :memory_store)
  @store_options          = options.fetch(:store_options, {})

  @store_options[:namespace] ||= @namespace

  initialize_store

  @cacheable_paths = %w(/edsapi/rest/Info /authservice/rest/uidauth /authservice/rest/uidauth /edsapi/rest/Retrieve? /edsapi/rest/Search? /edsapi/rest/ExportFormat /edsapi/rest/CitationStyles)

end

Instance Method Details

#call(env) ⇒ Object



31
32
33
# File 'lib/faraday/eds_caching_middleware.rb', line 31

def call(env)
  dup.call!(env)
end