class Frodo::Middleware::Caching
Public Instance Methods
cache_key(env)
click to toggle source
We don't want to cache requests for different clients, so append the oauth token to the cache key.
Calls superclass method
# File lib/frodo/middleware/caching.rb, line 16 def cache_key(env) super(env) + hashed_auth_header(env) end
call(env)
click to toggle source
Calls superclass method
# File lib/frodo/middleware/caching.rb, line 5 def call(env) expire(cache_key(env)) unless use_cache? super end
expire(key)
click to toggle source
# File lib/frodo/middleware/caching.rb, line 10 def expire(key) cache&.delete(key) end
hashed_auth_header(env)
click to toggle source
# File lib/frodo/middleware/caching.rb, line 24 def hashed_auth_header(env) Digest::SHA1.hexdigest( env[:request_headers][Restforce::Middleware::Authorization::AUTH_HEADER] ) end
use_cache?()
click to toggle source
# File lib/frodo/middleware/caching.rb, line 20 def use_cache? @options.fetch(:use_cache, true) end