Class: Cassette::Authentication::Cache

Inherits:
Object
  • Object
show all
Includes:
Cache
Defined in:
lib/cassette/authentication/cache.rb

Instance Method Summary collapse

Methods included from Cache

#backend, backend=, #backend=, #fetch, #uses_key

Constructor Details

#initialize(logger) ⇒ Cache

Returns a new instance of Cache.



12
13
14
# File 'lib/cassette/authentication/cache.rb', line 12

def initialize(logger)
  self.logger = logger
end

Instance Method Details

#clear_authentication_cache!Object



24
25
26
27
# File 'lib/cassette/authentication/cache.rb', line 24

def clear_authentication_cache!
  backend.delete_matched('Cassette::Authentication.validate_ticket*')
  backend.delete_matched("#{uses_key('Cassette::Authentication.validate_ticket')}*")
end

#fetch_authentication(ticket, service, options = {}, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/cassette/authentication/cache.rb', line 16

def fetch_authentication(ticket, service, options = {}, &block)
  options = { expires_in: 5 * 60, max_uses: 5000, force: false }.merge(options)
  fetch("Cassette::Authentication.validate_ticket(#{ticket}, #{service})", options) do
    logger.info("Authentication for #{ticket}, #{service} is not cached")
    block.call
  end
end