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.



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

def initialize(logger)
  self.logger = logger
end

Instance Method Details

#clear_authentication_cache!Object



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

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



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

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