Sha256: 485e7e83569530ce57d7e923073045f23f1b4bfb8f46389e8aa85e28b7b75972
Contents?: true
Size: 477 Bytes
Versions: 52
Compression:
Stored size: 477 Bytes
Contents
class ExvoAuth::Autonomous::Cache def initialize @data = {} end def read(key) o = @data[key] o[:value] if o && (now - o[:timestamp]) < 3600 # cache for one hour end def write(key, value) @data[key] = { :value => value, :timestamp => now } value end def fetch(key) if block_given? read(key) || write(key, yield) else read(key) end end private def now Time.now end end
Version data entries
52 entries across 52 versions & 2 rubygems