class Github::Authentication::ObjectCache
Public Class Methods
new()
click to toggle source
# File lib/github/authentication/object_cache.rb, line 8 def initialize @cache = {} end
Public Instance Methods
clear(key)
click to toggle source
# File lib/github/authentication/object_cache.rb, line 31 def clear(key) @cache.delete(key) end
read(key)
click to toggle source
# File lib/github/authentication/object_cache.rb, line 12 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
write(key, value, options = {})
click to toggle source
# File lib/github/authentication/object_cache.rb, line 24 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