class Github::Authentication::Cache

Public Class Methods

new(storage:, key: '') click to toggle source

storage = ActiveSupport::Cache

# File lib/github/authentication/cache.rb, line 9
def initialize(storage:, key: '')
  @storage = storage
  @key = "github:authentication:#{key}"
end

Public Instance Methods

clear() click to toggle source
# File lib/github/authentication/cache.rb, line 23
def clear
  @storage.delete(@key)
end
read() click to toggle source
# File lib/github/authentication/cache.rb, line 14
def read
  json = @storage.read(@key)
  Token.from_json(json)
end
write(token) click to toggle source
# File lib/github/authentication/cache.rb, line 19
def write(token)
  @storage.write(@key, token.to_json, expires_in: token.expires_in)
end