Sha256: 04aa6eebe1ae91235b698763d4e10585223b464b829915cfd0a0c426575e5667
Contents?: true
Size: 702 Bytes
Versions: 3
Compression:
Stored size: 702 Bytes
Contents
# frozen_string_literal: true require 'github_authentication/token' module GithubAuthentication class ObjectCache def initialize @cache = {} end def read(key) return unless @cache.key?(key) options = @cache[key][:options] if options.key?(:expires_at) && Time.now.utc > options[:expires_at] @cache.delete(key) return nil end @cache[key][:value] end def write(key, value, options = {}) if options.key?(:expires_in) options[:expires_at] = Time.now.utc + options[:expires_in] end @cache[key] = { value: value, options: options } end def clear(key) @cache.delete(key) end end end
Version data entries
3 entries across 3 versions & 1 rubygems