Class: CacheMiddalware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- CacheMiddalware
- Defined in:
- lib/binking/cache_middalware.rb
Constant Summary collapse
- DEFAULT_CONDITIONS =
->(env) { env.method == :get || env.method == :head }
- DEFAULT_CACHE_KEY =
->(env) { env.url }
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, store, *args) ⇒ CacheMiddalware
constructor
A new instance of CacheMiddalware.
Constructor Details
#initialize(app, store, *args) ⇒ CacheMiddalware
Returns a new instance of CacheMiddalware.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/binking/cache_middalware.rb', line 5 def initialize(app, store, *args) super(app) = args.first || {} @store = store @conditions = .fetch(:conditions, DEFAULT_CONDITIONS) @expires_in = .fetch(:expires_in, 30) @logger = .fetch(:logger, nil) @cache_key = .fetch(:cache_key, DEFAULT_CACHE_KEY) end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 |
# File 'lib/binking/cache_middalware.rb', line 16 def call(env) dup.call!(env) end |