Sha256: 7381e4fb062012f4d4420f9b3cdcb2fcada6f62e24cd84898dfcbfe454e597fb

Contents?: true

Size: 478 Bytes

Versions: 43

Compression:

Stored size: 478 Bytes

Contents

class ProconBypassMan::Procon
  class FlipCache
    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

    # for testing
    def self.reset!
      @@previous_flips_at_table = {}
    end

    reset!
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.12 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.11 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.10 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.9 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.8.1 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.8 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.7 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.6 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.5 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.4 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.3.1 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.3 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.2 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.1 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.3.0 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.2.3 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.2.2 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.2.1 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.2.0 lib/procon_bypass_man/procon/flip_cache.rb
procon_bypass_man-0.1.23 lib/procon_bypass_man/procon/flip_cache.rb