class ExvoAuth::Autonomous::Cache
Public Class Methods
new()
click to toggle source
# File lib/exvo_auth/autonomous/cache.rb, line 2 def initialize @data = {} end
Public Instance Methods
fetch(key) { || ... }
click to toggle source
# File lib/exvo_auth/autonomous/cache.rb, line 20 def fetch(key) if block_given? read(key) || write(key, yield) else read(key) end end
read(key)
click to toggle source
# File lib/exvo_auth/autonomous/cache.rb, line 6 def read(key) o = @data[key] o[:value] if o && (now - o[:timestamp]) < 3600 # cache for one hour end
write(key, value)
click to toggle source
# File lib/exvo_auth/autonomous/cache.rb, line 11 def write(key, value) @data[key] = { :value => value, :timestamp => now } value end
Private Instance Methods
now()
click to toggle source
# File lib/exvo_auth/autonomous/cache.rb, line 30 def now Time.now end