Sha256: e53afaa63ce239076276df6cace2997c5e4e41cecab4cb2d12bf45d8e54c872f
Contents?: true
Size: 769 Bytes
Versions: 1
Compression:
Stored size: 769 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] * 60 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.0 | lib/github/authentication/object_cache.rb |