Sha256: f7b6fd5f5dea83cf03258ff5e3c1249d1151d20c4772be0a564d5e32b15660ee
Contents?: true
Size: 698 Bytes
Versions: 1
Compression:
Stored size: 698 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 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
github-authentication-1.1.0 | lib/github_authentication/object_cache.rb |