Sha256: 1bf9095f7b90be20fb7949fff684c0acbc9371b38748aa51bb76a2f60057b092
Contents?: true
Size: 764 Bytes
Versions: 1
Compression:
Stored size: 764 Bytes
Contents
# frozen_string_literal: true require 'github/authentication/token' module Github module Authentication 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
github-authentication-0.1.2 | lib/github/authentication/object_cache.rb |