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=, #fetch, #uses_key

Constructor Details

#initialize(logger) ⇒ Cache

Returns a new instance of Cache.



9
10
11
# File 'lib/cassette/authentication/cache.rb', line 9

def initialize(logger)
  self.logger = logger
end

Instance Method Details

#clear_authentication_cache!Object



21
22
23
24
# File 'lib/cassette/authentication/cache.rb', line 21

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

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



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

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