Sha256: b93b62609c0f1f2eb95c3a41d32621446a4e75ddaa0806429c1236c7dfe5daa8

Contents?: true

Size: 510 Bytes

Versions: 1

Compression:

Stored size: 510 Bytes

Contents

# frozen_string_literal: true

require "github_authentication/token"

module GithubAuthentication
  class Cache
    # storage = ActiveSupport::Cache
    def initialize(storage:, key: "")
      @storage = storage
      @key = "github:authentication:#{key}"
    end

    def read
      json = @storage.read(@key)
      Token.from_json(json)
    end

    def write(token)
      @storage.write(@key, token.to_json, expires_in: token.expires_in)
    end

    def clear
      @storage.delete(@key)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github-authentication-1.1.0 lib/github_authentication/cache.rb