class ProconBypassMan::Procon::FlipCache
Public Class Methods
fetch(key: , expires_in: , &block)
click to toggle source
# File lib/procon_bypass_man/procon/flip_cache.rb, line 3 def self.fetch(key: , expires_in: , &block) if expires_in.nil? block.call else @@previous_flips_at_table[key] ||= Time.now if @@previous_flips_at_table[key] < Time.now @@previous_flips_at_table[key] = Time.now + expires_in block.call end end end
reset!()
click to toggle source
for testing
# File lib/procon_bypass_man/procon/flip_cache.rb, line 16 def self.reset! @@previous_flips_at_table = {} end